regex

Trouble with the simplest regex

I'm trying to validate an ASP TextBox that can only have 1-2 digits (not zero) using the following regex: ^[1-9]{1,2} This regex doesn't validate if the field is empty (assumed it would due to the 1-2 part) Also tried ^[1-9+]{1,2} to no avail. I'm clearly a newbie to regex so your help is appreciated. These are my controls: <asp:...

PHP preg_filter() substitute in PHP<5.3?

Had to deploy some PHP code onto a shared server with only PHP5.2.8. All code works EXCEPT for the preg_filter() call which was added in 5.3+ (and against which the code was written). Can anyone recommend an easy substitute for preg_filter() in PHP5.2? ...

special character at the begin who match with the end from every word [only regex]

what's best solution using regex, to remove special characters from the begin and the end of every word. "as-df-- as-df- as-df (as-df) 'as-df' asdf-asdf) (asd-f asdf' asd-f' -asdf- %asdf%s asdf& $asdf$ +asdf+ asdf++ asdf''" the output should be: "as-df-- as-df- as-df (as-df) as-df asdf-asdf) (asd-f asdf' asd-f' asd...

what does this sed expr. match actually? s/^.*EngineLog ERROR://

sed Expression 's/^.*EngineLog ERROR://' ...

Matching lines by number of words with regex

I am still new to regex and I've run into a bit of a problem. I am building a parsing script and I need to to be able to pull out lines with a certain length out of a file. How would I write a regex to match lines that have a certain number of words? Eg I want to match all lines in a file that have 3 words. Could I extend that to find...

RegEx to match String tokens in any order?

I'm looking for an Oracle Regular Expression that will match tokens in any order. For example, say I'm looking for "one two". I would want it to match both, "one token two" "two other one" The number of tokens might grow larger than two, so generating the permutations for the regex would be a hassel. Is there an easier way to do this...

Java Regex Problem Replacing a String

I am getting an exception when I try to do a replaceAll: Symbols is a valid string. private String buildQuery(){ String query = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(**QUERY**)&amp;format=json&amp;env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&amp;cal...

Python - Regular Expression Wildcards from Socket data?

Hello everyone. I have a question regarding regular expressions in Python. The expressions are composed of data that would be read from a server, connected via socket. I'm trying to use and read wildcards in these expressions. Example: Let's say I run a chat server. When a message is recieved, the server sends to all clients (JSmith send...

Java regex replaceAll does not replace string

I want the text "REPLACEME" to be replaced with my StringBuffer symbols. When I print symbols, it is a valid string. When I print my query, it still has the text REPLACEME instead of symbols. Why? private String buildQuery(){ String query = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%...

Determine regular expression's specificity

Hi, Given the following regular expressions: - alice@[a-z]+\.[a-z]+ - [a-z]+@[a-z]+\.[a-z]+ - .* The string [email protected] will obviously match all three regular expressions. In the application I am developing, we are only interested in the 'most specific' match. In this case this is obviously the first one. Unfortunately th...

Regex to match and return group names

I need to match the following strings and returns the values as groups: abctic abctac xyztic xyztac ghhtic ghhtac Pattern is wrote with grouping is as follows: (?<arch>[abc,xyz,ghh])(?<flavor>[tic,tac]$) The above returns only parts of group names. (meaning match is not correct). If I use * in each sub pattern instead of $ at the ...

clashing htaccess rules .php file extention still accessible

I have been trying to get my urls re-written. The first 4 rules are vital, but they are clashing with this line: (i think). RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.#?\ ]+)\.php([#?][^\ ]*)?\ HTTP/ this stops the url being able to be accessed like so www.example.com/page.php and redirects to www.example.com/page/ after adding the fir...

In flex, how to remove empty lines in text area?

In flex, how to remove empty lines in text area? ...

Big Regular expression help

Hi all, I've been pulling my hair out trying to come up with a regx that will pull the First and Last Name from the following HTML. My regex fu is not strong. <span id="label_85110"><b>First Name</b></span> <br/> <span id="value_85110">AWeber- Email Parser</span> <br/> </p> <p> <span id="label_86004"><b>Last Name</b></span> <...

Adjust Python Regex to not include a single digit in the findall results

I am trying to capture / extract numeric values from some strings. Here is a sample string: s='The shipping company had 93,999,888.5685 gallons of fuel on hand' I want to pull the 93,999,888.5685 value I have gotten my regex to this > mine=re.compile("(\d{1,3}([,\d{3}])*[.\d+]*)") However, when I do a findall I get the following...

JavaScript: remove insignificant trailing zeros from a number?

Have I missed a standard API call that removes trailing insignificant zeros from a number? Ex. var x = 1.234000 // to become 1.234; var y = 1.234001; // stays 1.234001 Number.toFixed() and Number.toPrecision() are not quite what I'm looking for. ...

Perl best practices: file parser using regexes and database storage

Hi, I'm writing a log file parser in Perl, using regexes that I've stored in a database. My workflow is basically like this: Looping over the file and searching for patterns matching my regexes and then extract them Do something with these matches Store them accordingly in a database Last time I did this I explicitly wrote each rege...

Regex exclude help?

Can anyone help me out with a Regex that will exclude words that are inside: title = "EXCLUDE ANYTHING HERE" THANKS! ...

Regular expression crashes Apache due to PCRE limitations. Need some help optimising!

Hey there. I am currently creating bbcode parsing engine and I have encountered a situation what i can't figure out on my own. The thing is, that I popped into a problem exactly like this one: http://stackoverflow.com/questions/3457039/apache-php-on-windows-crashes-with-regular-expression That means that if i make something like the ex...

Nesting preg_replace functions while escaping tokens.

I'm using the 'e' modifier in preg_replace to search for a given string. Then I need it to look within that string for individual matches using another preg_replace statement: $str = "This is FOO."; $str = preg_replace('/(foo)/ie', "x$1", $str); echo $str; This will generate: This is xFOO. Now I need to nest. (I'm nesting because I n...