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

5
votes
1answer
23 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
36 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
319 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
51 views

Searching text for a string

This is my current code: ...
3
votes
2answers
45 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 ...
7
votes
2answers
323 views

replace() for translating color names

I have some code to translate some color names, and this is what I did, quick and dirty. But I'm guessing there might be some function to replace arrays with arrays maybe, like in PHP, where you can ...
2
votes
1answer
81 views

Removing stray brackets from in between shortcodes

I was wondering if someone could point me in the right direction for cleaning up this code. WordPress uses shortcodes in the form [shortcode] to add extended functionality to posts and pages. What ...
3
votes
2answers
67 views

Regex to select the last components of a file path

I have a regex sequence that will take the end of a file path and select it for me for example: ...
6
votes
4answers
82 views

Extraction of numbers from currency string

I have the following code; whereas currency and views are in reality many JSON objects from an SAP export, that I can not rely ...
4
votes
3answers
63 views

Regex to find addresses and phone numbers

I am trying to optimize my Java code where I am parsing an address field. Address fields have the format: ...
20
votes
4answers
3k views

Someone thinks poorly of my server log parser

I have just been informed that the following code written by me is extremely poor. I have absolutely no idea why. It is memory efficient, and looks clean to me. But still the feedback is very poor. I ...
3
votes
3answers
291 views

DateTime-like class implementation in modern C++

In modern C++, there is no class like datetime in the standard which can be used in the program. However, with additional of modules like ...
3
votes
1answer
29 views

Faults using mod_rewrite

I never really bothered using mod_rewrite to achieve SEO friendly names but I've always admired from a distance because I've never been good at regex. The below .htaccess file does work, but I'm ...
4
votes
1answer
72 views

Fast regex to extract strings before and after a time

I want to get text1 and text2 by splitting time format Text1 10:24:02 Text2 Of the ...
8
votes
2answers
88 views

Generating and calling code on the fly

Delegate This class module defines what I'm calling, in this context, a Delegate - here a function that can take a number of parameters, evaluate a result, and ...
8
votes
1answer
358 views

Email validation using JavaScript

I have a function where I validate emails via a regex. I was wondering if this is the best regex to use or if there's a better way of doing it. Also is there a ...
4
votes
1answer
94 views

CodeEval Sequence Transformation

I've been working on this challenge for a week: There are two sequences. The first sequence consists of digits "0" and "1", the second one consists of letters "A" and "B". The challenge is to ...
4
votes
1answer
71 views

Regular expressions - match only specified string length

I'm learning regex. Here I'm checking a string of type aA1 but want also to check it is only 3 characters long. Is there a better way of doing it please? ...
1
vote
1answer
34 views

Using Regexp to select the date from a string [closed]

I have a string with date details with time, but I would like to show the day information alone. For that, I use the regexp to select the date. Can anyone tell me the regexp, and if what is used is ...
2
votes
1answer
56 views

Regex-ing an array

I am new using regex expression. After much digging I came up with this code. I would like to know if this is the correct way. I want to search in Joomla for some html tags with specific class and ...
4
votes
1answer
77 views

Deserialize an email header into key-value pairs

I've created a function that will deserialize an email header into a list of key-value pairs. I've run numerous tests using MS Office Outlook 2010 and MS Office 14.0 Object Library, all of which were ...
2
votes
2answers
116 views

Phone Number Extracting using RegEx And HtmlAgilityPack

I've written this whole code to extract cell numbers from a website. It is extracting numbers perfectly but very slowly, and it's also hanging my Form while Extracting. ...
1
vote
0answers
51 views

Using URLs and RegEx for web scraper from a dictionary [closed]

I have dozens of functions which GET/POST to some URLs and extract data using RegEx. The URLs and regular expressions were hard-coded earlier but now I moved all of them to a dictionary. I then saw ...
4
votes
1answer
52 views

Split a string of hostnames, expand from regex, return non-duplicated names in original order

I have the following function. It can be passed a candidate_string such as the following examples: "device1 device2" "device1" "device.*" "device.region" "device[123] Assume that target_list ...
11
votes
2answers
302 views

Markdown to HTML

...
6
votes
1answer
50 views

Expand hostnames from a string of hostnames and/or regex

This code will be passed a string which will contain one or more hostnames. A hostname can be dotted-decimal plain name (like my_host) FQDN or even partially ...
2
votes
2answers
30 views

Performance of RegExp vs Rune Loop

I was recently talking to someone about a function I wrote to mimic (very basically) the string interpolation function String.Format() found in the C# language. ...
3
votes
2answers
60 views

Align text (left, center, right) without additional packages

I wrote this short subroutine to left, center, right-align a multiline string. How can I make it better (shorter, prettier, optimized)? Can you offer some suggestions? ...
1
vote
1answer
77 views

Two implementations of website internationalization

I have attempted to create an internationalization system for my PHP framework that I'm working on. For the purpose I decided I will be using MySQL to store languages and translations. Respectively I ...
2
votes
1answer
56 views

Process a line in chunks via Regular Expressions with Ruby

I'm writing a Ruby script to reverse engineering message log files. They come from an external system with the following characteristics: Each line of the log file has at least one message. Each ...
10
votes
3answers
149 views

Match Simple Sentence or Partial Sentence

Description Match a Simple Sentence or a partial sentence Suitable for matching People Names (to some extent) Product Titles (to some extent) Correct use of apostrophe (to some extent) ...
7
votes
3answers
858 views

Replacing non-ASCII characters

I wrote a C# program to remove non-ASCII characters in a text file, and then output the result to a .NonAsciiChars file. The input file is in XML format. In fact, ...
5
votes
1answer
82 views

Do I have too many regexes in my validation logic?

The below function uses Javascript to validate a Belgian telephone number and format it according to the guidelines for phone number formatting. ...
2
votes
2answers
142 views

Validate multiple regexes without a for loop in JavaScript

For a project, I need to validate a VAT number against the correct algorithm. I found a library for this here (freeware, so I should be able to reuse it) that I'm grateful exists. However, I feel like ...
5
votes
3answers
190 views

Regex to validate font names

/((([\w -]+)|("[\w -]+"))( *, *)?)+/ http://refiddle.com/18ql I'm trying to use a PHP regex to sanitize a user input for a list of fonts. The above one seems to ...
6
votes
3answers
144 views

Pattern tokenization program

I am writing this program to try and get some practice at C++ and correct and proper styling. This code is meant to take user input from a pip and then run it through the program. The user enters a ...
5
votes
1answer
139 views

Generating the pretty bit at the end of a URL

I'm having a dip into F# and am attempting not to write it like it's C#. One area that bothers me is using members of System.String. These often need to be chained ...
5
votes
3answers
141 views

Cleaner or better readability in URL composition

I have a URL that is hardcoded via a config which I extract into a config: ...
3
votes
1answer
101 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 ...
7
votes
1answer
331 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
57 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], ...
27
votes
10answers
3k 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 ...
6
votes
1answer
55 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
38 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
675 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
3k 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 ...
3
votes
3answers
93 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
1answer
116 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
60 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;...
2
votes
1answer
54 views

Is this `img` creator decently secure from XSS?

This is being used now, seems decent to me but I'm curious. ...