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
2answers
40 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 ...
1
vote
1answer
34 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
80 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
46 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
312 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
64 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 ...
6
votes
0answers
78 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
156 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
38 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
22 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
53 views

Parsing a string to an object

I have this string containing this block of code: ...
7
votes
1answer
102 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
47 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
53 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 ...
1
vote
2answers
43 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
161 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 ...
-3
votes
1answer
47 views

Structure of regex to find selectors between angle brackets [closed]

Is the structure of this regex is correct? \[{1}+[\w]+\-?[\w]*(\=|\~|\||\^|\$|\*)*\"*?[\w]*(\-|\/)*[\w]*\.*[a-z]*\"*?\]{1} I want to use it to find selectors of ...
6
votes
2answers
149 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
54 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
43 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
43 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
44 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
440 views

Matching any certain selection of inputs

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
342 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
45 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
70 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
66 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 ...
2
votes
1answer
94 views

Page Spider in PHP

I have a working spider, however, it runs fairly slowly thanks to Australia's horrible internet. Can anyone give me some tips on speeding this up? ...
6
votes
2answers
250 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
82 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? ...
2
votes
1answer
45 views

Regex to extract selective lines

I have a list of error messages: ...
2
votes
1answer
51 views

Regex in combination with file compare

I have made a funtion to compare text files line by line, where timestamps and jobnumbers are replaced for a identical string. By lack of experience I'm not sure if this is the best way to do this. ...
7
votes
1answer
176 views

Finding Pattern score

You are given 3 strings: text, pre_text and post_text. Let L be a substring of text. For each substring L of text, we define pattern_score as follows: ...
8
votes
3answers
1k views

Transform snake_case to camelCase

I want to convert db columns such as is_deleted or product_code which consist of xx_xx to ...
4
votes
2answers
103 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 ...
4
votes
1answer
62 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. ...
2
votes
2answers
95 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
87 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. ...
1
vote
1answer
38 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
74 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
44 views

Conditionally splitting a string [closed]

I have a string that consists of one, two, or three fields. The full format is: "dest = comp ; jump" Either the dest or jump fields may be empty. If dest is ...
1
vote
1answer
54 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
42 views

Stripping leading tab of each line from a file

I've got this Python code: ...
10
votes
3answers
466 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
1answer
69 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
141 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
63 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
265 views

Vowels in a string, patterns

Checking if all five vowels are present in a string. ...
1
vote
1answer
47 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: ...