regex

C++::Boost::Regex Iterate over the submatches

I am using Named Capture Groups with Boost Regex / Xpressive. I would like to iterate over all submatches, and get both the value and KEY of each submatch (i.e. what["type"]). sregex pattern = sregex::compile( "(?P<type>href|src)=\"(?P<url>[^\"]+)\"" ); sregex_iterator cur( web_buffer.begin(), web_buffer.end(), pattern ); sregex_i...

Lighttpd rewriting files and directories

I'm trying to do url rewriting with Lighttpd. I have what I need partially working. Right now I have this: http://domain.com/name/a/123 which rewrites to http://domain.com/name/a.php?pid=123 I do this with this rewrite-once rule: "^/name/a/([^/]+)"=> "/name/a.php?pid=$1" That php page has external resources that are not getting rewritt...

Regex for getting spelling suggestions from aspell

Given this output from aspell, how can I can get the spelling suggestions: @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6) & knoledge 12 0: knowledge, knowledge's, pledge, ledge, kludge, sledge, Lodge, lodge, Coolidge, Noelle, knoll, nudge I cooked-up this regex: /[a-z\']+(?=,|\z)/i but I know it would fail i...

How to get a Clean String in Javascript?

i have a long String. With some German characters and lots of new lines tabs ect.. In a Selectbox user can select a text, on change i do document.getElementById('text').value=this.value; But this fails. I just get a "unterminated string literal" as error in JavaScript. I think i should clean the string. How can i do it in JavaScrip...

contenteditable realtime replace youtube url

so the problem is, i have a contenteditable div, with a keyup function binded. everytime somebody puts a youtube url in it, it has to be replaced by an embedded movie. i came up with a regex like this : content.match(/http:\/\/\w{0,3}.?youtube+\.\w{2,3}\/watch\?v=.*?(?=\s)/g); firefox wil do the replace after a whitespace, but in i...

multi-line pattern matching in pyhon

A periodic computer generated message (simplified): Hello user123, - (604)7080900 - 152 - minutes Regards Using python, how can I extract "(604)7080900", "152", "minutes" (i.e. any text following a leading "- " pattern) between the two empty lines (empty line is the \n\n after "Hello user123" and the \n\n before "Regards"). Even bet...

MySQL: searh by host name in field containing urls

Hello! I have this database table: id | url ----------------------------------------- 1 | http://stackoverflow.com/ 2 | http://www.google.com 3 | http://example.com/somepage 4 | https://another.net?id=88 5 | http://hello.org/index.php?hello=2 6 | http://google.com?q=hello+world I need to search all fields, where URL belo...

How to outperform this regex replacement?

After considerable measurement, I have identified a hotspot in one of our windows services that I'd like to optimize. We are processing strings that may have multiple consecutive spaces in it, and we'd like to reduce to only single spaces. We use a static compiled regex for this task: private static readonly Regex regex_select_all_...

PHP: Regular Expression to get a URL from a string

Possible Duplicates: Identifying if a URL is present in a string Php parse links/emails I'm working on some PHP code which takes input from various sources and needs to find the URLs and save them somewhere. The kind of input that needs to be handled is as follows: http://www.youtube.com/watch?v=IY2j_GPIqRA Try google: http...

Function evaluation disabled because a previous function evaluation timed out.

Hello everyone, I have an C# application in which I am getting this error : "Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation." I saw many posts related to this error on stackoverflow and on msdn also but found no solution. Most of the people say ...

Regular expression to match a name

What will be the regular expression in javascript to match a name field, which allows only letters, apostrophes and hyphons? so that jhon's avat-ar or Josh is valid? Thanks ...

win32 ruby1.9 regexp and cyrillic string

#coding: utf-8 str2 = "asdfМикимаус" p str2.encoding #<Encoding:UTF-8> p str2.scan /\p{Cyrillic}/ #found all cyrillic charachters str2.gsub!(/\w/u,'') #removes only latin characters puts str2 The question is why \w ignore cyrillic characters? I have installed latest ruby package from http://rubyinstaller.org/. Here is my output of r...

Can you use back references in the pattern part of a regular expression?

Is there a way to back reference in the regular expression pattern? Example input string: Here is "some quoted" text. Say I want to pull out the quoted text, I could create the following expression: "([^"]+)" This regular expression would match some quoted. Say I want it to also support single quotes, I could change the expressio...

regex jquery remove all double spaces

Hi I have this code, I want it to remove all the double spaces from a text area, but it will only remove the first occurrence each time. $(document).ready(function(){ $("#article").blur(function(){ ///alert($(this).val()); $(this).val($(this).val().replace(/\s\s+/, ' ')); }); }); I've also tried removeAll(), but it won't ...

Java RegEx API "Look-behind group does not have an obvious maximum length near index ..."

Hello, I'm on to some SQL where clause parsing and designed a working RegEx to find a column outside string literals using "Rad Software Regular Expression Desginer" which is using the .NET API. To make sure the designed RegEx works with Java too, I tested it by using the API of course (1.5 and 1.6). But guess what, it won't work. I got...

preg_replace - don't include string if $4 is blank

I have this expression: $regex_phone = '/^(?:1(?:[. -])?)?(?:\((?=\d{3}\)))?([2-9]\d{2})' .'(?:(?<=\(\d{3})\))? ?(?:(?<=\d{3})[.-])?([2-9]\d{2})' .'[. -]?(\d{4})(?: (?i:ext)\.? ?(\d{1,5}))?$/'; if(!preg_match($regex_phone, $data['phone'])){ $error[] = "Please enter a valid ph...

Tokenize a command string

I have string like this: command ". / * or any other char like this" some_param="string param" some_param2=50 I want to tokenize this string into: command ". / * or any other char like this" some_param="string param" some_param2=50 I know it's possible to split with spaces but these parameters can also be seperated by commas, like:...

Getting text between quotes using regular expression

I'm having some issues with a regular expression I'm creating. I need a regex to match against the following examples and then sub match on the first quoted string: Input strings ("Lorem ipsum dolor sit amet, consectetur adipiscing elit.") ('Lorem ipsum dolor sit amet, consectetur adipiscing elit. ') ('Lorem ipsum dolor sit amet, co...

Python Regex To VB.net

Hi everyone, I made a program in Python and now I whant to transfert it to vb.net. But I have some difficulties with the vb.net regular expression.... Someone can help me please? There are my Python regex: id = re.search('(?<=watch\?v\=)[\w|-]+|(?<=/v/)[\w|-]+', src) id = id.group(0) t = re.search('(?<=\&t\=)[\w|-]+', src) t = t.group...

regex for date in java

Hi , can someone help me what would be the regular expression in java for the string "Feb. 26, 2009 8:08 AM PST"???? ...