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.
2
votes
2answers
50 views
Want to sharpen my Python / Regex skills
I have a relatively simple project to parse some http server logs using Python and SQLite. I wrote up the code but I'm always looking for tips on being a better Python scripter. Though this is a ...
1
vote
0answers
60 views
Looking for a good heuristic in C# that will try to detect if the user is trying to search via regex [closed]
I am not sure if this question belongs here or on StackOverflow since my implementation, which compiles and sort of works is not the right solution, because I have not fully decided on what the ...
2
votes
1answer
31 views
Capturing optional regex segment with PHP
I need to check the end of a URL for the possible existence of /news_archive or /news_archive/5 in PHP. The below snippet does exactly what I want, but I know that I could achieve this with one ...
4
votes
1answer
71 views
Is my PHP script/embed remover robust?
The goal of this question:
Your goal here is to find a security hole in my code which allows a user to create input that contains a script doing anything they want, without that script being stopped ...
5
votes
1answer
144 views
Is there anyway to minimize the following code? combine regex for example?
i have built the following code using help from people at stackoverflow,
but i am pretty sure it can be minimized,but since i dont know regex very good (actually hardly), i do not know how to do it.
...
2
votes
2answers
101 views
String pattern matching - method needs improving
I'm trying to build simple pattern matching in a string.
ie., Given a template of: "Hello ${1}" and an input of "Hello world", I'd like to be able to return a map of 1='world'.
This test ...
1
vote
1answer
75 views
Lots of RegEx match against huge number range (PHP)
I have to check a given amount of regular expressions, which are defining number ranges for dial plans, against an input number range.
The target is to check and see, if any of the numbers in the ...
1
vote
1answer
52 views
Perl CGI script to respond to erroneous Base64 image requests
I often get lines like this in my Apache error log:
File does not exist: /path/to/www/data:image/gif;base64,R0lGODlhBgAGAIAOAP/yH5BAEACAEALAAAAAAGGAYAAAIJhB0Xi5vOoFwFADs=
Obviously, this is due to ...
3
votes
1answer
107 views
Implementation of Python's re.split in Clojure (with capturing parentheses)
If you use capturing parenthesis in the regular expression pattern in Python's re.split() function, it will include the matching groups in the result (Python's documentation).
I need this in my ...
6
votes
5answers
178 views
Can this regex for checking strong password be improved?
^(?=^.*[a-z])(?=^.*[A-Z])(?=^.*[0-9])(\S{8,})(?<!\s)$
Is there any way to make this regex more concise? Ensures a password has lowercase, uppercase, digit and is at least 8 characters, ...
1
vote
1answer
82 views
Need regex wizard to improve this - eliminating unwanted namespaces
Techies--
I know there's a better way to do this, but need an infusion of genius!:-) I am trying to eliminate unwanted namespaces. This code works, but its remedial and redundant.
string sPattern = ...
1
vote
1answer
89 views
Replacing the first n occurrences of a term
I originally posted this question on Stack Overflow and it was suggested that it be moved here
Inspired by this question I thought to write my own jQuery function that would replace the first n ...
1
vote
0answers
86 views
Extension Method for Creating Types from Regular Expression Match Groups
I've been doing some parsing with regular expression named capture groups and decided it might make sense to write an extension to handle this.
The code below will create an instance of a specified ...
1
vote
1answer
71 views
Improving a shortcode replacement routine PHP and regex
I am using wordpress to allow a client to enter a curriculum vitae and have it output the correct and consistent html formatting:
So I have a plain text box custom field and am having them enter in ...
0
votes
2answers
87 views
I need help to improve this REGEX (repetead characters and space after punctuation)
I'm trying to "sanitize" a textarea input by disallowing repetead characters like "!!!", "???", etc. add spaces after commas, and I would like to optimize the code because I'm not a PRO at this...
...