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

1
vote
0answers
36 views

Automatic condensing of whitespace in HTML

One of the things that has occurred to me more recently is that if you add up all of the bandwidth that is taken up by thousands of users downloading the newlines and tabs used to make HTML source ...
6
votes
1answer
32 views

Convert WKT representations of geometries into GeoJson

I am working on a class library in C# to convert WKT to GeoJson. I am getting shapes in WKT out of MSSQL. A lot of the shapes ...
2
votes
1answer
42 views

Is this regular expression optimizable (reduced match steps) [closed]

Requirement that need to handle: only ascii letters in lower register [a-z], digits [0-9], ...
20
votes
9answers
2k views

What are some indicators that I was over-thinking my solution to this problem?

This question is a cross between career question and a code review. I was uncertain where to ask, but since there is code involved I went with CodeReview. I’m going through the process of technical ...
4
votes
1answer
35 views

Canonicalizing a large set of addresses using many regex substitutions

I have a script that is standardizing a large amount of data in the database. The standardization involves applying over 500 regular expressions to the data. Here is some quick pseudocode: ...
2
votes
1answer
30 views

Cheat Code Scraper

During breaks, I find myself playing Emerald version a lot and was tired of having to use the school's slow wifi to access the internet. I wrote a scraper to obtain cheat codes and send them to my psp ...
7
votes
2answers
574 views

Optimizing and improving a username regex

I have created this regular expression to validate usernames which I need in my projects: ...
6
votes
5answers
1k views

Regex validation for Email Address

I need to validate whether my regex is correct for below scenario. Suggestion's if the regex is correct: Wiki Link Local_part The local-part of the email address may use any of these ASCII ...
2
votes
1answer
37 views

More Pythonic version of finding substring with one glob-like expression

Giving the following example list the task is: find out whether the second expression is in the first one. * shall be considered as a wildcard for any ...
2
votes
2answers
66 views

Preg_match pattern for user input filtering

My users may need to supply a 'disease category' to my site. I need to let them use all alphanumeric characters, hyphens and single quotes. Would someone review this to see if they feel it's ...
5
votes
1answer
40 views

Negative Lookbehind Regex

I have the following code which attempts to match all strings like "*SOMESTRING" (which can include numeric values), but not "*SOMESTRING*". For this I am using a negative lookahead as follows;...
0
votes
0answers
23 views

Regular expression to match 25 IP addresses in Google Analytics [migrated]

I was having issues with a RegEx. Mainly I wanted to create a filter to only find these 25 IP addresses in Google Analytics: 216.54.215.0 216.54.215.1 216.54.215.2 ... 216.54.215.24 I first ...
2
votes
1answer
45 views

Is this `img` creator decently secure from XSS?

This is being used now, seems decent to me but I'm curious. ...
2
votes
2answers
37 views

Determine if a path matches a pattern

I have been struggling with a regular expression involving path names. Immediately, this is a bit troublesome, owing to the embedded / in the pattern, but braces to the rescue. First the convention ...
7
votes
2answers
202 views

Check whether a list of list of string fits a regex efficiently

I have the following structure for my object: Word (Object) Word (String) List<Symbol> Symbol (Object) ...
3
votes
1answer
69 views

Breaking after one of several string replaces occur

I have a script that matches a string against ~20 different regexs for the purpose of changing it. They are ordered and formed that the string will only ever match against one. How can I avoid ...
7
votes
3answers
102 views

VB6/VBA Declaration (Dim) Syntax Parser

As part of a project I'm working on, I've implemented a class that encapsulates the syntax for a vb6/vba Dim statement. Given a line of code, the ...
1
vote
0answers
37 views

VerbalExpressions in Scala

I forked the original implementation of VerbalExpressions in Scala here: https://github.com/pathikrit/ScalaVerbalExpressions I am looking forward to these things in the code review: ...
1
vote
2answers
49 views

Parsing BLAST output in XML format using Regular Expression

There many other better ways to parse BLAST output in .xml format, but I was curious to try using regex, even if it is not so straightforward and common. Here is the code how to extract translated ...
5
votes
1answer
51 views

Combining two indexOf and regex in to one

I have the following code that splits a combination of names on either the word and or the & ampersand: ...
5
votes
3answers
316 views

Regex match for a string in a URL

I feel like there is too much repetitive code going on here. All I am doing is doing a basic regex match for a string in the URL. If a match is found, I find an li with a class (.index, .grid, .type) ...
4
votes
2answers
49 views

Efficient use of regular expression and string manipulation

The following is my solution to Java vs C++. I think the way I have used the re library is inefficient, and possible erroneous as I am getting tle. ...
2
votes
1answer
83 views
4
votes
1answer
69 views

Converting snake_case to CamelCase

Is there an effective way, maybe with regex, to change the following text pattern? I have a string like abc_def_ghi_jkl. I want to replace it to ...
1
vote
1answer
139 views

Is this a safe way to parse out HTML tag attributes?

I needed a super simple parser to get HTML attributes and their values. I didn’t want to load a big library or anything so I made this. I realize I am making assumptions here, mainly: Attribute ...
3
votes
1answer
44 views

How to simplify Regex with Data.Text?

This function tells that elements of content either (maybe) match regexes that you like or match regexes that you don't like. This messy code requires ...
2
votes
1answer
28 views

Parsing playlists efficiently

I have this regexp working, simple, but I feel like it may not be the best way to code it. Basically, I have a playlist separated by line breaks returned as tcp data like so: ...
11
votes
4answers
1k views

What would be preferred aesthetically and performance wise?

Which one of these two would you prefer writing in your code? This: ...
1
vote
4answers
143 views

Best way to comment regex

Regular expressions are one of the worst aspects of debugging hell. Since they are contained in string literals, It's hard to comment how they work when the expressions are fairly long. Say I have ...
2
votes
2answers
111 views

Speeding up and fixing phone numbers from CSVs with Regex

I've hodgepodged together an attempt to extract all phone numbers from all CSVs in a directory, regardless of where they are and what format they're in. I want all phone numbers to be printed to a ...
4
votes
1answer
40 views

Communicating between plugins whilst maintaining context in Javascript

I'm making some changes to a JavaScript plugin on a site I've been made steward over. This main plugin has it's own sub-plugins and I'm trying to make certain aspects modular. Currently, I'm ...
6
votes
1answer
164 views

BBCode to HTML converter using functional programming

I was inspired to write a BBCode to HTML converter as I'm currently learning functional programming. I wanted achieve functional cohesion. jsFiddle I'd like feedback on: structuring of the code. ...
4
votes
2answers
63 views

Packaging a single-file Python copy-tool

I'm currently working on a very simple one-file project: Lumix provides the possibility for the camera TZ41 (and others) to load GPS data and tourist information from a DVD to a SD-card so that you ...
3
votes
1answer
46 views

Generate regular expression based on inputted number

This is my first PHP script (although I like to think I'm a good general coder). The script accepts a number from the user, uses it to generate a regular expression, and then returns all dictionary ...
6
votes
2answers
77 views

Performance tuning on a text file to object conversion

I'm using an API which returns text in the following format: ...
7
votes
4answers
399 views

Bring phone numbers in consistent format

I'm using this code to bring my phone numbers in a consistent format. Desired: +(country code)phone number Possible patterns: ...
2
votes
1answer
77 views

Check for invalid name

I'm trying to write a regular expression to check names for invalid entries. Basically I'm trying to eliminate people entering random junk as their name. I know I can't completely eliminate it but I'm ...
1
vote
0answers
15 views

How can I clean up this hack to scrape paths from a Gruntfile?

As a part of my Tabv Vim plugin (which at this stage is nothing more than a pitiful rag-tag assortment of half-baked hacks), I have a function which attempts to guess the directory paths for main ...
4
votes
2answers
126 views

Extract version string from text file with Powershell

I need to pull the version # out of a Vim script that might look something like: ...
1
vote
1answer
65 views

1-line conditional statement needs to be trimmed down

I have this conditional statement with use of regex: ...
10
votes
1answer
109 views

A regular expression parsing library in C

I've created a regular expression (regex) parsing library in C, and would like some feedback on it. Speed is really important to me, but any and all suggestions are acceptable. ...
1
vote
1answer
156 views

All possible values that will match a regular expression

This is a similar question to this, but I am looking for the set of all possible values that will match a regular expression pattern. To avoid an infinite set of possible values, I am willing to ...
6
votes
2answers
76 views

Another regex subset matcher

After reading @JavaDeveloper's recent question, I was inspired1 to try my hand at writing code to accomplish the same task. The "rules" for this code (i.e., its intent) is to match a subset of ...
5
votes
1answer
131 views

Regex parser implementing dot, star and question mark

Regex parser which follows the following rule . (dot) means a any single character match * (star) means 0 or more ...
3
votes
2answers
141 views

Counting the words in a textarea

I've two working ways to do so, but which one should I use? Common part: var textarea = document.getElementById("textarea"); First way: ...
10
votes
1answer
86 views

Locating matching files with input folder and file prefix

This is my first more-than-1-line script. It takes an input folder and a file prefix and gets all the matching files. For the first of the files, the script grabs the first line and appends an extra ...
3
votes
2answers
108 views

Parsing annotation

I have implemented code for parsing annotation: ...
7
votes
1answer
291 views

HTTP Authorization header parser

I'm writing a parser for HTTP Authorization header (see RFC2616#14.8 and RFC2617#1.2). Note that I explicitly don't care about the base64-encoded syntax used by HTTP Basic authentication. I'm only ...
2
votes
2answers
355 views

Whitelist HTML tags Microsoft Sanitizer and custom Regex

I have the following code which I have written due to the fact the Microsoft's Sanitizer is now to aggressive. What I'm trying to do is as follows. Create a whitelist of HTML tags I want to keep ...
2
votes
1answer
135 views

Dice notation roller in JavaScript

I have the following function, intended to take standard dice notation (XdY+Z) and return a (sort of) random number based on the input. Are there any bugs/bad ideas/optimizable sections I am missing? ...