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.
1
vote
1answer
31 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
20 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
23 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
119 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
94 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
28 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 ...
5
votes
1answer
84 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
47 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
35 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
69 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
213 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
64 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
14 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 ...
3
votes
0answers
39 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
61 views
1-line conditional statement needs to be trimmed down
I have this conditional statement with use of regex:
...
10
votes
1answer
74 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
80 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
64 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
66 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
118 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:
...
9
votes
1answer
70 views
Help speeding up my first Bash script
This is my first more-than-1-line script. It takes an inputfolder and a file prefix and get all the files matching. For the first of the files, the script grabs the first line and appends an extra ...
3
votes
2answers
90 views
7
votes
1answer
113 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
201 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
92 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?
...
10
votes
2answers
286 views
Matching script tags with regexes
Like anything that shouldn't be done, I decided to see if it is possible to match <script> tags robustly using regexes in PHP. Since there is no arbitrary ...
4
votes
1answer
350 views
Getting data correctly from <span> tag with beautifulsoup and regex
I am scraping an online shop page and I am trying to get the price mentioned in that page. In the following block, price is mentioned:
...
5
votes
1answer
105 views
Trying multiple regexes against a single string
I have a huge list of regexes (>1,000 but <1,000,000) that I want to test against (many) single strings.
It is unlikely and unintended that more than one such expression would match a single ...
7
votes
5answers
230 views
Reading from text file with RegexMatch
Below is the method that I have written for reading from a text file. While reading, I need to match line string to given regex and if it matches then I need to add the line string to a collection.
...
3
votes
1answer
110 views
6
votes
1answer
122 views
Calculate query coverage from BLAST output
I have a BLAST output file and want to calculate query coverage, appending the query lengths as an additional column to the output. Let's say I have
2 7 15
...
8
votes
2answers
185 views
Recursive Regular Expressions
I want to first search for a specific regular expression.
If it is not found then I would like to search for another regular expression
If that one is also not found then I would like to search for a ...
0
votes
2answers
719 views
Remove a parameter and its value from URL's query string
I'm coding an algorithm to remove a parameter (let's call it foo) from URL strings.
Of course, after the foo parameter removal, ...
7
votes
1answer
142 views
How could I improve this map-reduce code?
I have been changing this code and I don't get to make it much better, I changed a little bit the structure, reimplemeted a new function for splitting Strings which is more efficient, etc. I have been ...
4
votes
4answers
80 views
1
vote
1answer
72 views
TCPDUMP file (part of a real capture)
I have been working on this code for quite a while and just want to make sure it is up to good standards. I know many of you will have questions, so as they come up, I will edit my initial question to ...
3
votes
2answers
91 views
Either or case in Python and Regex
I have a small module that gets the lemma of a word and its plural form. It then searches through sentences looking for a sentence that contains both words (singular or plural) in either order. I have ...
2
votes
3answers
652 views
Convert Sql LIKE to Regex
I have a bit of code that converts a Sql Like expression to a regex expression for the purposes of a Linq to objects Like extension method. For some time I have ...
6
votes
3answers
178 views
A regex in Java. Latin letters, digits, dots, and minus signs
There is a user login, and the requirements are the following:
The login must start with a Latin letter.
The login must finish with either a Latin letter or a digit.
There may also be digits, ...
2
votes
1answer
58 views
3
votes
3answers
63 views
Limited typecasting with regex
long time user/lurker at stackoverflow, first time here. I've seen a lot of questions like this have people point to this section of the StackExchange network so I hope this is the right place.
I'm ...
4
votes
1answer
182 views
Regex parser - request for review and optimization
The whole question is Better implementation of a simplified regular expression engine?.
I have solved the question, and in turn felt the need to get it reviewed. Any suggestions for clean up and ...
0
votes
2answers
82 views
Reducing number of blank spaces
This program takes blank spaces before some chars like > < />, and if there is more than one blank space in the line, it will reduce to one.
...
5
votes
2answers
760 views
What do you think of my regex for URL validation?
I would like you to review my regex. It's suppose to recognize common URLs like:
...
1
vote
2answers
284 views
Performance: getting first value from comma delimited string
I've got a string that has values that are delimited by comma's, like so:
$var = '1,23,45,123,145,200';
I'd like to get just the first value, so what I do is ...
2
votes
1answer
414 views
How to replace plain URLs with links, in javascript? [closed]
I've nearly got this working. I wanted to know if there is a much better way. One problem is that no matter what there will be cases where a URL is incorrectly identified and as such the end result ...
3
votes
1answer
116 views
Optimize regex for maximum speed
According to http://stackoverflow.com/questions/19608546/optimize-regex-for-maximum-speed
and comments to ask my question here .
Please help me to optimize following regex to best performance . I have ...
1
vote
2answers
124 views
How do you “sordid sort” alphanumeric strings?
The question is about sorting alphanumeric string in a "more natural" order. Source: Marc LeBrun's "Sordid Sort" Computist Quiz
Often a system string comparison sorts alphanumeric data ...
1
vote
2answers
176 views
Trying to improve my javascript code in this simple challenge from coderbyte
Here is a slightly modified challenge from Coderbyte:
Determine if a given string is an acceptable. The str parameter will be composed of + and = symbols with several letters between them (ie. ...