Regular expressions are a declarative language, mainly used for pattern matching within strings. Please include a tag specifying the programming language you are using, together with this tag.

learn more… | top users | synonyms

2
votes
2answers
44 views

URL pattern matching

The whole process mainly depends on the ProcessFile() function: I get all the credentials and details from a JSON file. Initially I get data from the db: two IDs ...
0
votes
1answer
19 views

Class for interpretation of capturing groups inside regex

I wrote a class, which intends to work with regular expression (as a String or Pattern object) to get capturing groups of given ...
1
vote
1answer
15 views

Print first element of the last line of files when the second element does not match a pattern

I am relatively new to Bash, regular expression and stuff. In a directory, I need to read the last line of all the files that contain the word "fitness", and list (on one line and separated with ...
4
votes
1answer
38 views

IE compatibility mode detection

This method is written for much larger Web application, but I just extracted it and added class and main method around it so that it can be debugged locally. Browser detection is done in another ...
4
votes
1answer
37 views

Deleting most recent files by parsing filename

I have hundreds of .mp3 files in a single directory of the same naming format, title_YYYY-MM-DD.mp3, with maybe 30 different ...
2
votes
1answer
69 views

HackerRank Regex Challenge: Detect HTML Tags

Problem Statement In this problem you will use regular expressions to help you detect the various Tags used in an HTML document. Here are a few examples of tags: The "p" tag for ...
7
votes
5answers
358 views

CodeEval Challenge: Remove specified characters from a string

Question Write a program which removes specific characters from a string. The first argument is a path to a file. The file contains the source strings and the characters that need to be ...
2
votes
1answer
65 views

Parsing a component of a regex followed by an optional quantifier character

I have a piece of parsec code that parses a unit optionally followed by ?, + or ...
3
votes
1answer
34 views

Removing ASCII “frame” around text

I sometimes save nice fortune outputs to my Evernote. The data looks like this: ...
2
votes
4answers
55 views

Parsing time if valid

I need to parse only valid timestamp formats: Hours followed by minutes followed by seconds: t=1h2m3s Minutes followed by seconds: ...
6
votes
1answer
98 views

Phone number extraction with regular expressions

I've been working on my own phone number extraction snippet of Regex code and I'd appreciate your feedback on it. I've tried to make it match as many different types of numbers as I knew existed in ...
3
votes
0answers
21 views

Repetitive replacement for expressing fractions in LaTeX

I am converting natural math expressions with fractions to Latex code. What I have done seems to work on examples I've tested, but I'm not sure if the algorithm is safe. And maybe the string part ...
8
votes
2answers
346 views

These words are so dirty

Challenge: Write a program that will clean up the words from extra numbers and symbols. Specifications: The first argument is a path to a file. Each line includes a test case with a list ...
6
votes
1answer
39 views

Sentence maker with thesaurus

I'm teaching myself Ruby by rewriting PHP solutions, such as this one. The program should match words in a sentence with a dictionary of synonyms and then make combinations with them. ...
4
votes
2answers
105 views

Using sed regular expression to extract domain name from file

I'm learning regex with sed to extract the last field from file named "test". The method I'm trying gives desired output. Please suggest if this method Im trying is ...
2
votes
2answers
45 views

Prettifying URLs for a PHP-based club website

I have a website for my car enthusiast club ("example.org") whose content can be divided into three main sections: Startseite (the "front page" of the site), Mitglieder (membership directory), and ...
4
votes
1answer
105 views

Hackerrank regex solution

I solved the following problem on Hackerrank. The challenge is to: Parse HTML input and display the tags and attributes in lexicographically ascending order. This is the input format: ...
2
votes
1answer
46 views

Visualization of regex analysis

As I started to learn about regular expressions, and as part of bigger project, I wrote a regex analyzer, which: takes the PROPER regular expression, takes the String already MATCHED by this regex, ...
5
votes
1answer
26 views

Redirect for subdomains and secondary domains

I've just edited my .htaccess file. All works as it should, but I'm not too familiar with regular expressions and want to make sure that there aren't any unintended ...
0
votes
1answer
19 views

Combine keycode regex and variable array

I am using the following code to try and only allow letters, numbers, backspace, space, dashes, slashes, and ampersands. I also want all other keys including the function keys (F1, F2, etc) to be ...
3
votes
4answers
259 views

Product Manager managing product listings and prices

For school we have to develop a product manager. The basic task is to add new products. A product has a name and a price. I know the one or other class is currently pretty empty but its planned to ...
4
votes
2answers
50 views

Bash script to replace substrings in a file with strings

I am an editor of the Funtoo Linux wiki and was looking to create a shell script that would help to ease the updating of pages on the wiki that use old tags by replacing certain deprecated tags with ...
2
votes
1answer
43 views

Advanced multi-conditonal split with an regex in Perl

I would like to split a string on multiple conditions such as: After each /;/ After each /{/ or ...
5
votes
1answer
86 views

Finding word acronyms for telephone numbers

Having read most of Learn You a Haskell as well as parts of Real World Haskell, I decided to embark on an easy project to see if I can apply the Haskell that I've learned. ...
1
vote
1answer
24 views

Inserting filename, reading data, inserting regex, and testing if each line matches - version 2

This is a improved version of the program seen in my older question. This program first displays a menu which shows some options that the user can select. Each option will the respective functions ...
3
votes
1answer
50 views

Inserting filename, reading data, inserting regex, and testing if each line matches

This program first displays a menu which shows some options that the user can select. Each option will the respective functions which do some things. The user can insert a filename, read data from ...
5
votes
3answers
324 views

Getting 6 possible URL parameters

I am in the midst of writing a simple job board and I have the URL's filtering and working how I want, everything works - I just want to know if I can improve it, if there are any security concerns, ...
2
votes
1answer
70 views

TDD: String Calculator Kata

String Calculator Create a simple String calculator with a method int Add(string numbers). The method can take 0, 1 or 2 numbers, and will return ...
7
votes
0answers
92 views

Debug statement remover

I've been fiddling around with some programs, and since most of them are for fun, I haven't bothered with little things like making the output non-verbose until I, say, put it here, for review. I was ...
5
votes
1answer
180 views

Extracting emails from a file and writing them to another file

The code below works fine for me. Is there any way that I can improve this code more? Note: delimiter is single whitespace only for email address. getmail.py ...
0
votes
2answers
40 views

Compare JS files and pick according to requirement

Problem Statement: Extract the filename and read if filename has jQuery on it, put them aside. Second step will be to check one more and see if any jQuery files has ...
2
votes
1answer
27 views

Convert “String” sqrt(#) into numerical value

I had to come up with a way to convert sqrt(#) into its actual numeric value because before I would have an array containing elements such as: ...
4
votes
1answer
56 views

Parsing a string to an object

I have this string containing this block of code: ...
7
votes
1answer
108 views

Validation macro

I would like a review of a Scala validation library I am writing. For now we can focus on the regular expression component. The usage is described in RegexExample.scala There is an outline of the ...
2
votes
0answers
104 views

Truncating text with jQuery but keep the HTML formatting

I repeat here this answer on Stack Overflow. I first posted an answer with not finalized code, as a simple description of the solution I could think, without any test. But later I remained ...
5
votes
1answer
63 views

Retrieving all the email addresses on a web page

I recently discovered the file_get_contents function and wanted to put it to some use, alongside preg_match_all, off the ...
0
votes
2answers
60 views

Avoiding regexps abuse in generation of statements to be executed

I made a GPL project to read Shogi Western Notations that I made public in GitHub. The project works perfectly on Ubuntu. Please check README.md to check requirements. All this code works quite well. ...
5
votes
3answers
214 views

Replacing all occurrences in a String

I have a string like this : val content = "some_text{macro1}another_text{macro2}text" I want to replace the {macro1} and ...
6
votes
2answers
156 views

Performing multiple validation checks

I have a validation which checks that a string is a valid asset number. There are currently three formats it could be in, like: 001-123456, ...
1
vote
1answer
60 views

Formatting HTML for use in a locally hosted iframe

This formats HTML for use in a locally hosted iframe so that you can manipulate the content in the iframe freely, without running into cross domain issues. It uses Goutte to retrieve the HTML. I'd ...
2
votes
2answers
49 views

RNA/DNA transcriber

I've been going through some of the exercises over on exercism and this is one of my solutions: a basic RNA/DNA transcriber. I was happy enough at first but now, looking at it again, the solution ...
1
vote
1answer
79 views

Search string by regex in files and write line of found string

I am searching in files with extensions .xml, .java, and .properties strings that match a certain regular expression. When I find it, I write it to the file with the filename, line and string ...
2
votes
1answer
67 views

A1Notation conversion to row & column index

This set of Google Apps Script helper functions are published in this gist, along with a bunch of other utilities. Background info is in this SO question. Since no Google services are used, this is ...
5
votes
2answers
444 views

Matching any certain selection of inputs [closed]

I have the following RegEx which matches any of a selection of inputs (see the list below). While it works fine, I'm wondering if there is a better way of writing it, as it looks a little dirty. ...
6
votes
2answers
458 views

Writing an IRC Bot from scratch

I have been learning C# for a couple years now, and using small projects to help myself learn. My most recent project is a complete rewrite of my first C# project that just got out of hand (the old ...
5
votes
2answers
52 views

Converting domain-specific regular-expressions to a list of all matching instances

There seem to be several questions floating around Stackexchange regarding how to take a python regular expression list the matching instances. This problem is a bit different because 1) I'm need to ...
4
votes
2answers
78 views

C++ regex golf solver program much slower than original Python

I am rewriting Peter Norvig's Python regex golf solver in C++. I had originally planned to post the whole thing here at once when I was finished, but: This program takes double the time of the ...
3
votes
2answers
69 views

Parsing a URL from a document and matching it from an array

I need help in improving this script that I have written to parse a URL and check it from an array. This is what I have done till now: (fiddle) This is working fine. Was this done correctly? What ...
6
votes
2answers
355 views

Removing Asterisks and neighbors from a string

I am going through the CodingBat exercises for Java. I got to this problem: Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its ...
1
vote
2answers
90 views

Match all youtube links in a string of text

I'm looking to pull all the youtube links from a string of text and was wondering how does this look? ...