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

3
votes
1answer
13 views

Counting words from standard input in Swift

I know Swift isn't exactly meant to be used to write your classic stdin to stdout scripts, and that Python, Ruby, Perl, bash, awk, and friends are much better in this area, but I'd still like to see ...
0
votes
0answers
102 views

Perl 5 IO Manipulation and Regex [on hold]

I've been having some fun with IO file manipulation and regex. I'm sort of lost on how to go about implementing the TODOs and other possible failsafes to make sure this program runs as intended (as ...
2
votes
2answers
30 views

Shorter cleaner technique of writing code with variables and lists?

How can I make my code more pythonic ? I definitely think there is a way to make this code a lot more readable and clear + shorter... But I haven't found an effective way. Any techniques I can use to ...
2
votes
0answers
20 views

Compile-Time Wildcard Pattern Matching

I was in need of a function that could check a string against a certain pattern at compile-time. The pattern can contain any of the commonly known wildcards: ?, * and +. ...
2
votes
1answer
16 views

Optimize a regex validating a version string

I develop an application which installs updates. These updates have a version id (this version id is created as a part of the application and the format is a fixed requirement) and I use a regex to ...
8
votes
1answer
66 views

Find/replace number with commas in Java

I have a requirement to put a comma between each digit of a number in a Java string. Example input: the number is 12345 and the number is 45678 The output ...
-1
votes
0answers
20 views

Checking regex pattern efficiency [on hold]

I have some strings like: @HELLO) AND @X @Y1) AND @TEST I am using this Regex: @[?\w?]\) AND @[?\w?] that detects ...
2
votes
3answers
168 views

Remove repetitive strings from a given sentence efficiently

I recently gave a test on HackerRank: Given a string, return the most concise string that can be formed from it. For example: ...
6
votes
1answer
214 views

Regular Expression matching customer number strings

Using VB.NET, I have created an AddIn for Autodesk Inventor and the customer has a bunch of drawing number strings which follow this sort of scheme: ...
4
votes
2answers
74 views

A method to capitalize the first letter of all words in a String

I recently was given a task to capitalize the first character of a string provided the string does not begin with a non-alphabet. Below are the requirements and my implementation. Just want to know if ...
2
votes
1answer
11 views

String replacement in OCaml

This is part of my first OCaml program. Its job is to replace a set of placeholder characters with umlauts. Taking the German word Ruebe as an example, the program ...
4
votes
1answer
43 views

Network chat in Perl

I have written a network chat program as my first major project in Perl. It makes simple use of REGEXP's, modules, sockets, command-line option parsing, and forking and uses these features to produce ...
0
votes
1answer
20 views

Check the address String for presence of a New Brunswick abbreviation

I need to check if there are any abbreviation of New Brunswick province in the address. Acceptable abbreviations are: "NB", "N.B.", "N-B", "N.-B." and any combination of upper-lower cases. It ...
2
votes
1answer
63 views

Regular Expression for parsing PHP annotations containing multiple lines and markup

I am writing a regular expression for parsing PHP annotations in a flexible way. I'd like to accomplish all the goals listed above with one single expression. So I would appreciate any suggestions ...
0
votes
1answer
50 views

Yet Another Regex-Based MarkDown to HTML converter

I wrote a simple script to translate (a subset of) StackExchange markdown to HTML. I used Regex for this task, but luckily I only had to use simple patterns. ...
1
vote
2answers
46 views

Clean regex matches with named matches

I have a regex pattern that will match some elements from a string and give them a particular name. For example, #^(?<foo>.*)^# will match the whole string ...
-1
votes
1answer
30 views

Extracting Power and Energy out of a slow regex

My WinForms application is a bit slow, I'd like to make it faster. It extracts only the power and energy values out of a string in textBox3, and displays the ...
7
votes
2answers
104 views

Get Wikimedia attributions for images

We are using images from Wikimedia commons for some of Cardshifter's game artwork. I selected some art for each card to make a .jpg file to use in the game clients, ...
4
votes
2answers
69 views

Function that shortens a String based on a term/abbreviation mapping with special cases

This is a update of this question since the requirements for this task changed. I have a function that takes a description as a String and returns a shortened ...
21
votes
4answers
3k views

“ONCE”, “UPON”, “A”, “TIME”

I'm working on a small program to perform various tasks on text content, primarily at the word level. I wrote these methods as ways to help prepare the raw text file into something more malleable, ...
5
votes
2answers
40 views

Regex for finding After Effects files in scene code format

I haven't used regex a lot and I needed to set up a script that can gather a list of file paths that should adhere to a strict formatting convention, so I thought that sounded like a good opportunity ...
-8
votes
3answers
145 views

Regular expression to match all binary strings with even number of ones and zeros [closed]

POSIX version: ^((00)*|(11)*|((10|01)(\2|\3)*(10|01))*)++$ Emacs version: ...
10
votes
3answers
473 views

Fastest possible text template for repeated use?

While reviewing Sending templatized e-mail to a million contacts, I wrote this implementation to illustrate an alternate approach. It is designed to be the fastest possible way to generate templated ...
2
votes
2answers
61 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 ...
4
votes
3answers
125 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
19 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
60 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
44 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
100 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
374 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
68 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
35 views

Removing ASCII “frame” around text

I sometimes save nice fortune outputs to my Evernote. The data looks like this: ...
2
votes
4answers
59 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
111 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 ...
5
votes
1answer
33 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
355 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
42 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
145 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
54 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
162 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
61 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
30 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
23 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
282 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
54 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
47 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
87 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. ...
3
votes
1answer
35 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 ...
5
votes
1answer
64 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
337 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, ...