regex

Given the following JS/JQUERY, how to prevent it from being case sensitive

I have the following line of code which works well: $("a.grouped_elements[href$=.jpg],a.grouped_elements[href$=.png],a.grouped_elements[href$=.gif]").fancybox(); Problem is, if the href is .JPG it doesn't work it only works with .jpg. How can I make the above case insensitive so either all caps or no caps or a mix all match for the fi...

preg_match_all to parse an xml-like attribute string

I have a string like so: option_alpha="value" option_beta="some other value" option_gamma="X" ...etc. I'm using this to parse them into name & value pairs: preg_match_all("/([a-z0-9_]+)\s*=\s*[\"\'](.+?)[\"\']/is", $var_string, $matches) Which works fine, unless it encounters an empty attribute value: option_alpha="value" option_b...

Regular Expression to match unlimited number of options

I want to be able to parse file paths like this one: /var/www/index.(htm|html|php|shtml) into an ordered array: array("htm", "html", "php", "shtml") and then produce a list of alternatives: /var/www/index.htm /var/www/index.html /var/www/index.php /var/www/index.shtml Right now, I have a preg_match statement that can split two...

Use regular expressions with Glib

Hello, I would like to find all comment blocks(/*...*/) but the function g_regex_match_full always returns true. Here is the code : // Create the regex. start_block_comment_regex = g_regex_new("/\*.*\*/", G_REGEX_OPTIMIZE, 0, &regex_error); //Search the regex; if(TRUE == g_regex_match_full(start_block_comment_regex, current_line, -1, 0...

Track results of a regular expression extractor in JMeter

Our server returns a custom 'X-Execution-Time' HTTP response header that returns in miliseconds the time between the server getting a request and our code returning a page, ie how long our code takes to run. I'm using JMeter to do some testing & I'd like to be able to report on this number of over time. I've setup this regular expressi...

AJAX - querying a search engine and returning the number of results

Right, so basically I need to query a selection of search engines in an AJAX app. As there is a number of different search engines - there's no search engine specific API I can use either. My main problem is getting the number of results returned by the search. So far, I have decided it is probably best to use a regexp from the returned...

postgres - regex_replace in distinct clause?

Ok... changing the question here... I'm getting an error when I try this: SELECT COUNT ( DISTINCT mid, regexp_replace(na_fname, '\\s*', '', 'g'), regexp_replace(na_lname, '\\s*', '', 'g')) FROM masterfile; Is it possible to use regexp in a distinct clause like this? The error is this: WARNING: nonstandard use of \\ in a string lit...

What should be the RegEx if I want to find the text between the phrases " IF (NEW." and " !"?

What should be the RegEx if I want to find the text between the phrases " IF (NEW." and " !"? Likewise I am thinking of the pattern as $pattern = '/(?<= IF (NEW.)[^ !]+/'; I am matching it as $input = $row4['ACTION_STATEMENT'];`/*BEGIN IF (NEW.name != OLD.name) THEN INSERT INTO jos_menuaudit set menuid=OLD.id, oldvalue = OLD.name, ne...

Preg_match if a string beginns with "00"{number} or "+"{number}

Hy i have to test if a string begins with 00 or with + Say i have the string 0090 or +41 if the string begins with 0090 return true, elseif string begins with +90 replace the + with 00 else return false The last two digits can be from 0-9 How do i do that in php? I hope i could explain my question clear? ...

How to improve my Python regex syntax?

I very new to Python, and fairly new to regex. (I have no Perl experience.) I am able to use regular expressions in a way that works, but I'm not sure that my code is particularly Pythonic or consise. For example, If I wanted to read in a text file and print out text that appears directly between the words 'foo' and 'bar' in each line...

Only replace first matching element using PHP's mb_ereg_replace

Hello, I want to replace only the first matching element in a string instead of replacing every matching element in a string $str = 'abc abc abc'; $find = 'abc'; $replace = 'def'; echo mb_ereg_replace( $find, $replace, $str ); This will return "def def def". What would I need to change in the $find or $replace parameter in order to ...

Fastcgi 500 error on preg_match_all in PHP

I'm trying to set up some exotic PHP code (I'm not an expert), and I get a FastCGI Error 500 on a PHP line containing 'preg_match_all'. When I comment out the line, the page is returned with a 200 (but not how it was meant to be). The code is parsing PHP, HTML and JavaScript content loaded from the database and is composing them to ret...

Regular Expression avoiding characters up to code 255

Dear Masters! Is it possible to ensure, that only characters with codes between 0 and 255 will be accepted by regular expression, but all with the codes up to 256 not? Thank you! ...

How can I convert Perl regular expressions to boost regular expressions?

What is equivalent to perl expression: /ing$|ed$|en$/ in boost regular expression? Words end with ing or ed or en should match with reg expression in boost! ...

Regex to match the first file in a rar archive file set in Python

I need to uncompress all the files in a directory and for this I need to find the first file in the set. I'm currently doing this using a bunch of if statements and loops. Can i do this this using regex? Here's a list of files that i need to match: yes.rar yes.part1.rar yes.part01.rar yes.part001.rar yes.r01 yes.r001 These should NO...

Regex Not Matching Unicode

How would I go about using Regex to match Unicode strings? I'm loading in a couple keywords from a text file and using them with Regex on another file. The keywords both contain unicode (such as á, etc). I'm not sure where the problem is. Is there some option I have to set? Code: foreach (string currWord in _keywordList) { Match...

Strip out C Style Multi-line Comments

I have a C# string object that contains the code of a generic method, preceded by some standard C-Style multi-line comments. I figured I could use System.Text.RegularExpressions to remove the comment block, but I can seem to be able to get it to work. I tried: code = Regex.Replace(code,@"/\*.*?\*/",""); Can I be pointed in the right...

Regular expression to match Amsterdam postcodes

can any one tell me regular expression for postalcode of Amsterdam, Netherlands for validation EX. 1113 GJ Postal code format according to Wikipedia (thanks to Pekka): 1011–1199 plus a literal suffix AA-ZZ, e.g. 1012 PP ...

Regular expression with "|"

I need to be able to check for a pattern with | in them. For example an expression like d*|*t should return true for a string like "dtest|test". I'm no regular expression hero so I just tried a couple of things, like: Regex Pattern = new Regex("s*\|*d"); //unable to build because of single backslash Regex Pattern = new Regex("s*|*d"); ...

Using the @ symbol to identify users like twitter does

I'm creating my own version of twitter, I have no idea how to get my back end php script to pick up the @membername within the entered text. Including multiple @membername's for example @billy @joseph, @tyrone,@kesha message or @billy hit up @tyrone he's bugging @kesha about the money you owe him. Any scripts of use on how I can ac...