regex

help with regex match

i want to retrieve following urls with a regex: HREF="http://www.getty.edu/vow/TGNFullDisplay?find=&place=&nation=&english=Y&subjectid=7009830" HREF="http://www.getty.edu/vow/TGNFullDisplay?find=&place=&nation=&english=Y&subjectid=7009830&ptype=PF" the difference is the ending. the first one omit...

Remove stuff, retrieve numbers, retrieve text with spaces in place of dots, remove the rest...

Hi All!! This is my first question, so I hope I didn't mess too much with the title and the formatting. I have a bunch of file a client of mine sent me in this form: Name.Of.Chapter.021x212.The.Actual.Title.Of.the.Chapter.DOC.NAME-Some.stuff.Here.ext What I need is a regex to output just: 212 The Actual Title Of the Chapter ...

use regular expression in if-condition in bash

Hi, I wonder the general rule to use regular expression in if clause in bash? Here is an example $ gg=svm-grid-ch $ if [[ $gg == *grid* ]] ; then echo $gg; fi svm-grid-ch $ if [[ $gg == ^....grid* ]] ; then echo $gg; fi $ if [[ $gg == ....grid* ]] ; then echo $gg; fi $ if [[ $gg == s...grid* ]] ; then echo $gg; fi $ ...

Regular expressions for validating a mailing address.

Hi alll I have strings like follow field_zip_code:"48103" taxonomy:88 field_zip_code:"48103" taxonomy:88 field_state:"MI" field_zip_code:"48103" From here i want to extract variable values like 48103,88,MI i need regular expressions in PHP, Thanks in advance Kamal ...

How to determine if a PHP string ONLY contains latitude and longitude

I have to work with strings which may contain Lat/Long data, like this: $query = "-33.805789,151.002060"; $query = "-33.805789, 151.002060"; $query = "OVER HERE: -33.805789,151.002060"; For my purposes, the first 2 strings are correct, but the last one isn't. I am trying to figure out a match pattern which would match a lat and long ...

SQL Server and regular expressions

Hello ! Which will be better among following option ? Regular-expressions in SQL Server searches, as new versions support CLR objects ? Full text search ? Lucene.net combined with SQL Server ? Our database will be having millions and millions of records and we will be providing Google-like search option, and like Google sea...

How do you debug a regex?

Regular expressions can become quite complex. The lack of white space makes them difficult to read. I can't step though a regular expression with a debugger. So how do experts debug complex regular expressions? ...

How to match any whitespace in body of mail in procmail?

I tried to use such rule: :0 B * Something[[:space:]]+whatever but it doesn't work. When I change [[:space:]] to literal space character: :0 B * Something +whatever it works. It also works in case of: :0 B * Something[ ]+whatever I must be doing something wrong, but can't really find it. Any hints? ...

C# foreach loop with key value

In PHP I can use a foreach loop such that I have access to both the key and value for example: foreach($array as $key => $value) I have the following code: Regex regex = new Regex(pattern); MatchCollection mc = regex.Matches(haystack); for (int i = 0; i < mc.Count; i++) { GroupCollection gc = mc[i].Groups; Dictionary<string...

YSOD Yellow Screen Of Death JavaScript RegExp - Syntax Error

I built up this regex at http://regextester.com to parse YSOD but VS is complaining about a syntax error. I am sure I am missing an escape somewhere but I am coming up blank. Here is is in original form. any help is appreciated. var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*\n)*?)\s*(at(.*\n)*)-->/gs; UPDATE: Kobi pointed out the obvious...

Struggling with number regex match

Hi, I'm trying to match only numbers and spaces in my php regex but the following fails and I can't seem to understand why, can anyone shed some light on what I'm doing wrong please? $pattern = '/^[0-9\ ]$/'; Thanks ...

Problem (un-)greedy RegExp

Consider the following Strings: 1: cccbbb 2: cccaaabbb I would like to end up with are matches like this: 1: Array ( [1] => [2] => bbb ) 2: Array ( [1] => aaa [2] => bbb ) How can I match both in one RegExp? Here's my try: #(aaa)?(.*)$# I have tried many variants of greedy and ungreedy modifications but it doe...

How can I check with cucumber & webrat & selenium that a selector/tag exists exactly two times in a response?

I used following step-definition with cucumber and webrat and everything worked fine: Then /^I should see "([^\"]*)" worker in the workerlist/ do |number| response.should have_selector("td.worker_name", :count=>number) end I have moved now to selenium and "somehow" the have_selector doesn't take a :count parameter anymore. I get fo...

Fuzzy Regular Expressions

In my work I have with great results used approximate string matching algorithms such as Damerau–Levenshtein distance to make my code less vulnerable to spelling mistakes. Now I have a need to match strings against simple regular expressions such TV Schedule for \d\d (Jan|Feb|Mar|...). This means that the string TV Schedule for 10 Jan s...

Matching UTF Characters with preg_match in PHP: (*UTF8) Works on Windows but not Linux

I have a simple regular expression to check a username: preg_match('/(*UTF8)^[[:alnum:]]([[:alnum:]]|[ _.-])+$/i', $username); In local testing (Windows 7 using WAMP), this will allow for usernames using UTF characters (such as é or ñ). However, when I move to test this on the server where the site will actually be hosted, I get the f...

Grails Createcriteria for subquery

Hi, How to use createCriteria for subQuery . My HQL is like this : def lists = List.executeQuery("FROM List cl WHERE cl.brand_id in (SELECT b.id FROM Brand b WHERE cl.brand_id=b.id AND b.brand_name rLIKE '^[0123456789].*')") Please tell how can we write this using Createcriteria ?? thanks in advance. ...

PHP preg_match_all returns nothing

I am trying to extract all img tags from an HTML string. See the code $d1 = file_get_contents("http://itcapsule.blogspot.com/feeds/posts/default?alt=rss"); preg_match_all('/<img[^>]+>/i',$d1,$result); print_r($result); And the result is Array ( [0] => Array ( ) ) But the same regex gives correct result in an online regex test...

Removing whitespace in Java string?

Hi guys, I'm writing a parser for some LISP files. I'm trying to get rid of leading whitespace in a string. The string contents are along the lines of: :FUNCTION (LAMBDA (DELTA PLASMA-IN-0) (IF (OR (>= #61=(+ ...

question about javascript string's replace method

Hi guys, I know that I can pass a string as the second parameter to the JavaScript string object's replace method. In this case I can use $` and $' to reference the left/right part text of a successful match. Now my question is, If I pass a callback function as the second parameter, how can I get the same information? I want to use this...

regex in php for finding words

i want code for the following example.... example.... $words = "The sculpture was selected during a design competition. After Kapoor's design was chosen, numerous technological concerns regarding the design's construction and assembly arose, in addition to concerns regarding the sculpture's upkeep and maintenance. Variou...