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

4
votes
1answer
42 views

Normalizing strings using PHP preg_replace and regex expressions

I needed a way to normalize nearly any given input for a configuration parameter on a dashboard. Server side code is in PHP so I wrote a test script to experiment with ...
2
votes
0answers
18 views

Evaluating an expression with integers, +, and *, as well as -, / - revision 3

The original question came from this web site. Revision 1 Revision 2 And this is the third revision. I delete spaces and validate an equation before computing. ...
0
votes
1answer
27 views

Regex to search and replace text in a large file

I am searching for a multiline pattern in a huge file and if found need to replace the contents. I want to accomplish this in a memory efficient way. My current implementation reads text from file in ...
1
vote
1answer
60 views

Converting file from Markdown-like markup into HTML using repeated substitutions

The following code reads a file, splits its data, replaces some characters in the data, and then joins the data again (I added more details in the comments): ...
5
votes
1answer
41 views

Parsing error messages using regular expressions in Java 8

I have a below method in Java 8 which checks for message pattern and finds the line number from the message. ...
-4
votes
0answers
18 views

Regex replace special characters defind by client [closed]

I need a c# function which will replace all special characters customized by the client from a string Example ...
1
vote
1answer
24 views

Parsing logs in sed efficiently

I have an application which log file has most lines start with a time/date, followed by a debugging level and the actual log message. Often I want to watch the output live and colors make it a lot ...
4
votes
1answer
42 views

Link to WinRT XAML code optimization

I need a method which will parse text to RichTextBlock-compatible XAML markup with clickable links. Example: Input: ...
-2
votes
1answer
33 views

Conditionally splitting a string [closed]

My requirement is: dest = comp ; jump // Either the dest or jump fields may be empty. If dest is empty, the "=" is omitted; If jump is empty, the ";" is omitted. So I may have something like ...
1
vote
1answer
36 views

Filename interpreter for TV shows

I have small class which interprets TV show filenames to extract the show title and episode number. Due to the nature of the filenames, I have chosen for a cleaning approach: I clean the filename ...
1
vote
1answer
35 views

Stripping leading tab of each line from a file

I've got this Python code: ...
10
votes
3answers
210 views

Empty Line delimiter, single line output

I'm used to only processing, at most, one line of a file at a time. This is my first time changing the delimiter, and the objective here is to take a file containing lines such as: ...
1
vote
0answers
29 views

Efficient Strip Special Characters

I have a private function in PHP that takes a given URL string and just leave the Alpha or numeric and certain punctuation left. I need the stripping of string due to having it match against ...
3
votes
0answers
84 views

Efficient JavaScript/jQuery typewriter effect that handles HTML5, entities, and text

How should this code be improved? For instance: How could it be shorter, clearer, deal with memory better, use a plugin/library, better prepared for web input? I can break up and clarify the regex ...
2
votes
0answers
34 views

Search/sort/create functionality, implements bubblesort and sequential search

I've moved my main() to the bottom of the code block in order to fit it all in one class for this submission. If there is a better way to do it? ...
2
votes
2answers
155 views

Vowels in a string, patterns

Checking if all five vowels are present in a string. ...
1
vote
1answer
45 views

Find free username based on schema

Hopefully this is not too complicated. I have this code that will generate a username based on the pre-configured schema the admin types in. The fields they can use are: ...
1
vote
2answers
30 views

Repeatedly fetching a URL until the response contains “state: INIT”

I am working on a project in which I need to make a URL call to one of my servers from a bash shell script. http://hostname.domain.com:8080/beat After hitting the above URL, I will be getting ...
4
votes
2answers
90 views

Press any login button on any site

I'm working on a script that will be able to press the login button on any site for an app I'm working on. I have it working (still a few edge cases to work out such as multiple submit buttons and ...
1
vote
1answer
47 views

A simple Ruby EmailAddress class

I wrote this short, plain Ruby lib to handle email address validation inside and outside of Rails applications, and I would like to know what you think. ...
5
votes
1answer
56 views

Regex to parse URIs for their correctness according to RFC 3986

I recently came to write a regex to parse URIs. Now I wonder, did I miss something? Did I make a mistake or could I have written it cleaner? That's why I'm here. In order to write the regex, I took ...
2
votes
1answer
46 views

SMS relay --> MySQL database

The main purpose of my program is to extract GPS information from text messages sent to several GSM modems send from various GPS tracking devices. The main flow of my program loops in three steps: ...
4
votes
1answer
65 views

Multiplying Lists

Challenge: Given 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists Specifications: Your program should accept as its first argument a ...
1
vote
2answers
34 views

Redirecting all pages under a certain directory to a single file

I want to redirect all pages under a certain directory to a single file, like so: /dir/a/dir/new ...
5
votes
3answers
153 views

Optimize huge text file search

I have several huge 100MB text files that I need to scan through to pick out certain frame numbers which relate to a specific log packet of interest. My plan was to scan for these frame numbers and ...
2
votes
2answers
57 views

Pulling thread data from Invision power board from an external java application

What I am planning on doing is pulling the first post of my news section, this was made for V bulletin and now I need to add it for IPb. ...
3
votes
3answers
225 views

Inserting persons in file into SQLite

I've just started working with SQLite in C# to test various features of an application. In building my first SQLite example I wanted to insert a large .csv into a table (Person) with two columns, A ...
13
votes
1answer
657 views

Capitalize the first character of all words (even when following a '-')

I got it working, all variations are displayed Sint-Anna as should be, but I wonder, is there a simpler way to this, since it looks very cluttered? ...
5
votes
1answer
158 views

Regex for matching a US phone number

I have written my first regex: ...
1
vote
1answer
59 views

An easier way to test a valid username

I have the following requirement for valid usernames: Only alphanumeric characters and - Must not start with a - I wrote this regex (on Rubular): ...
-3
votes
1answer
41 views

Regex for allowing only alphanumerical characters [closed]

This is my first regex: ^[a-zA-Z0-9][a-zA-Z0-9\/]*[\/]$ I want to: Only match alphanumeric at the beginning The last character must be a "/" Only alphanumeric ...
1
vote
2answers
52 views

Regex to Match Email address

I have the below regex to match email address with atleast one @ and one . ...
3
votes
1answer
75 views

Regex for curly quotes and apostrophes

After years of fear and procrastination I decided to learn regular expressions. This is the result: CoffeScript: ...
0
votes
0answers
32 views

Dynamically display relevant form elements

Here is a group of questions (hidden by default except the first one) with yes|no buttons ...
5
votes
3answers
124 views

Follow-up to Morse Code String

This is probably one of the many follow-ups coming. What I have edited: Added equals() and hashCode() Added ...
1
vote
0answers
64 views

HTML to plain text converter

Please, review the code below. Test class: ...
2
votes
1answer
140 views

HTML Compressor with regex

I would like to compress a Magento HTML page using some regex, and this is what I have written: ...
5
votes
3answers
57 views

Extract room sizes & room types from an estate description with regex

I'm trying to extract room types and sizes from a descriptive text utilizing the following scripts as an exercise. Any tips on being more pythonic would be amazing! The script is based off the help I ...
13
votes
2answers
170 views

I think I might be having a regex nightmare

I've been working on the Rubberduck (an add-in for the VBA Editor /"VBE"), specifically here the VBA.Parser namespace. Here's how I ended up implementing the syntax ...
4
votes
0answers
124 views

Parsing Lua 5.2 strings with patterns

I wrote some code to parse Lua 5.2 strings in Lua 5.1, using patterns. It's a bit too slow, but it works fine as far as I tested. ...
0
votes
2answers
66 views

Optimizing regex alternation, ability to view which choice matched?

So I've got a regular expression parsing tcp responses from a music daemon. In case responses pile up I've come up with an expression to separate full responses from the data, however I'd like to also ...
6
votes
2answers
56 views

Perl 6 oneliner to sum up all numbers in a text file

The task is to sum up scores mentioned in a text file. Scores are floating point numbers as defined by the regexp float immediately preceded by a * character to ...
2
votes
0answers
52 views

Replace while loop with sed

I have a script for school that mimics the cp command. Part of the assignment is to modify the script so that the while loop (that assigns stdin to the variable filelist) is instead done with sed. ...
5
votes
1answer
252 views

Regex matching keys in a Dictionary

I have extended this class http://wiki.unity3d.com/index.php/CSharpMessenger_Extended to accept strings containing wildcards as eventTypes, therefore I am able to ...
10
votes
1answer
55 views

Automatic report generation from BibTeX

I wrote the following code for the question I asked here. Are there any catastrophic mistakes? (actually it did not really work with perltex and I am in doubt about having syntax mistake(s)) Also, I ...
5
votes
3answers
58 views

Some simple Perl and Regex

Reads from a flat file of three columns, delimited by at least one tab character. Filters the three columns based on input; returns list of corresponding emails. Arguments passed like ...
6
votes
2answers
354 views

The Bucketizer Script

This code is written in a SSIS Script Component that basically accomplishes what I previously had as a T-SQL script, that was reviewed here. I need to split a 80 character string that contains 20 ...
2
votes
3answers
79 views

Searching text for a string

This is my current code: ...
4
votes
2answers
72 views

Substituting Hebrew letter variants

I have two functions that replace letters. In one function, I'm replacing a regular Hebrew letter with its final form, and the other function undoes this operation. (Consider it like ...
3
votes
1answer
60 views

Checking whether a word satisfies a template with wildcards

I'm working one of the recommended tutorials -- actually, the UPenn online course CS194 -- for learning Haskell, and I have a working solution to the final "challenge exercise" for HW 2. But it seems ...