regex

C# and Regex: How to extract strings between quotation marks

Assume I have the following string: <script language="javascript"> var league = new Array( "Soccer","Germany - 2. Bundesliga","38542195","102","24 May 2009 14:00","24 May 2009 14:00","1X2","1","0" ); var matches = new Array( "125","1.FC Nurnberg - TSV 1860 Munich","24 May 2009 14:00","Sun, 24.05.09 14:00","1|...

Regular Expression Sub Problems

Okay so i have a semi weridish problem with re.sub. Take the following code: import re str_to_be_subbed = r'somefile.exe -i <INPUT>' some_str = r'C:\foobar' s = re.sub(r'\<INPUT\>', some_str, str_to_be_subbed) print s I would think it would give me: somefile.exe -i C:\\foobar But instead it gives me: somefile.exe -i C:♀oobar I ...

proofs about regular expressions

Does anyone know any examples of the following? Proof developments about regular expressions (possibly extended with backreferences) in proof assistants (such as Coq). Programs in dependently-typed languages (such as Agda) about regular expressions. ...

PHP Regex Question

I have a series of urls in a web doc, something like this: <a href="somepage.php?x=some_document.htm">click here</a> What I want to do is replace the bold piece: <a href="somepage.php?x=some_document.htm">click here</a> .. with some sort of encrypted variation (lets just say base64_encoding) .. something like this: for each match, ...

How to implement a SQL like 'LIKE' operator in java?

I need a comparator in java which has the same semantics as the sql 'like' operator. For example: myComparator.like("digital","%ital%"); myComparator.like("digital","%gi?a%"); myComparator.like("digital","digi%"); should evaluate to true, and myComparator.like("digital","%cam%"); myComparator.like("digital","tal%"); should evaluate...

Regex Pattern for Whitespace

I am creating a regex library to work with HTML (I'll post it on MSDN Code when it's done). One of the methods removes any whitespace before a closing tag. <p>See the dog run </p> It would eliminate the space before the closing paragraph. I am using this: public static string RemoveWhiteSpaceBeforeClosingTag(string text) { ...

How do I build Perl regular expressions dynamically?

I have a Perl script that traverses a directory hierarchy using File::Next::files. It will only return to the script files that end in ".avi", ".flv", ".mp3", ".mp4", and ".wmv." Also it will skip the following sub directories: ".svn" and any sub directory that ends in ".frames." This is specified in the file_filter and descend_filte...

Expression parsing: how to tokenize

I'm looking to tokenize Java/Javascript-like expressions in javascript code. My input will be a string containing the expression, and the output needs to be an array of tokens. What's the best practice for doing something like this? Do I need to iterate the string or is there a regular expression that will do this for me? I need this t...

Javascript text to link replacing

I need to replace text into link in Link must be look like " href="/search?q=$oldtext" title="$oldtext" ". $oldtext is text to replace. I'm tried to use loop to find text with regexp "/^\x23\w/",and replacing with variable that contain generated link. And it result to nothing. I've edit regexp to "/\x23/" and get replacing for "#" (\x...

RegEx-how to parse html page for pattern (in JavaScript)

I need to parse the html page for a patern. I am assuming that the matches are loaded into an array. And then I need to output the contents of the array. <script language="JavaScript" type="text/javascript"> var adBookmarkletData=[ '<html><head><title>MYSA Yahoo! APT Debugger</title></head><body><center><div style=\"background:#ccc;colo...

Regular expression for a string that does not start with a sequence

I'm processing a bunch of tables using this program, but I need to ignore ones that start with the label "tbd_". So far I have something like [^tbd_] but that simply not match those characters. ...

How can I exclude specific words from a generic regular expression?

Possible Duplicate: Regular Expression to exclude set of Keywords Hi, I have the following regular expression which matches everything actually :-). However I need to exclude some specific strings from matching. I know I have to use the exclamation (!) sign, but I can't seem to get it working. Either way the strings don't get e...

Pad an integer using a regular expression

I'm using regular expressions with a python framework to pad a specific number in a version number: 10.2.11 I want to transform the second element to be padded with a zero, so it looks like this: 10.02.11 My regular expression looks like this: ^(\d{2}\.)(\d{1})([\.].*) If I just regurgitate back the matching groups, I use this st...

Pulling international street addresses / phone numbers from free-form text

Hey, folks. I'm looking for some regular expressions to help grab street addresses and phone numbers from free-form text (a la Gmail). Given some text: "John, I went to the store today, and it was awesome! Did you hear that they moved to 500 Green St.? ... Give me a call at +14252425424 when you get a chance." I'd like to be able to...

What's the "ruby way" to parse a string for a single key/value?

I am trying to parse a multi line string and get the rest of the line following a pattern. text: hello john your username is: jj thanks for signing up I want to extract jj, aka everything after "your username is: " One way: text = "hello john\nyour username is: jj\nthanks for signing up\n" match = text[/your username is: (.*)/] va...

Regexp for cleaning the empty, unnecessary HTML tags

I'm using TinyMCE (WYSIWYG) as the default editor in one of my projects and sometimes it automatically adds <p>&nbsp;</p> , <p> </p> or divs. I have been searching but I couldn't really find a good way of cleaning any empty tags with regex. The code I've tried to used is, $pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/"; $str = preg_replace(...

RegExp in ActionScript 3: How to exclude a complex prefix?

Hi, AS3 RegExp engine (and ECMAScript based JavaScript) do not support complex "lookbehind" expressions. (lookahead expressions are fully supported.) For example: (?<=<body>)(.*?)(?=<\/body>) will work but; (?<=<body\b[^>]*>)(.*?)(?=<\/body>) will not work in AS3. What I need is to match a complex prefix but exclude it in the ...

<?PHP, REGEX and me. A tragedy in three acts.

Hi everyone, long time listener. First time caller... Not strictly a PHP question as it involves regular expressions but this one has got me tearing my hair out. I have 3 regular expressions that I want to create, and only one is working correctly. Now I am not sure whether this is due to the fact that: I don't understand preg_match...

What do these regex Patterns Match?

I am new to regex in PHP and understand the basic patterns however the ones below are a bit complex and I don't understand what the following pattern matches: $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#... "<a href='' rel='nofollow'></a>", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[...

Regex Question: Matching this pattern with hard or soft quotes

Hello, I have this achor locating regex working pretty well. $p = '%<a.*\s+name="(.*)"\s*>(?:.*)</a>%im'; It matches <a followed by zero or more of anything followed by a space and name=" It is grabbing the names even if a class or an id precedes the name in the anchor. What I would like to add is the ability to match on name=' wi...