regex

Eclipse regex search/replace not replacing after regex positive look-ahead?

After I do a positive lookahead in eclipse 3.5, I am unable to do any sort of replace! Specifically, I put in any text string to replace the found string, and the text string is unable to be replaced. My positive lookahead is at the end of the line so as to include the positive lookahead text in the next search. What's up? This is also ...

Multiple matches within a regex group?

Hey all! I need to match all 'tags' (e.g. %thisIsATag%) that occur within XML attributes. (Note: I'm guaranteed to receive valid XML, so there is no need to use full DOM traversal). My regex is working, except when there are two tags in a single attribute, only the last one is returned. In other words, this regex should find tag1, ta...

Regexp for replacing quotes in database insert statements

I'm converting a sqlite3 database to mysql. I have a nice command file for sed that changes AUTOINCREMEMT and the other things needed, but I'm stuck on the last one: double quotes. sqlite3 dump format: CREATE TABLE "products" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "desc" varchar(255) ); INSERT...

How are nested capturing groups numbered in regular expressions?

Is there a defined behavior for how regular expressions should handle the capturing behavior of nested parentheses? More specifically, can you reasonably expect that different engines will capture the outer parentheses in the first position, and nested parentheses in subsequent positions? Consider the following PHP code (using PCRE reg...

Emulating SQL LIKE in JavaScript

How can I emulate the SQL keyword LIKE in JavaScript. For those of you who don't know what LIKE is, it's a very simple regex which only supports the wildcards %, which matches 0 or more characters, and _ which matches exactly one character. However, it's not just possible to do something like var match = new RegEx(likeExpr.replace("%",...

Create regular expression to get rid of illegal character patterns in PHP

In PHP, what is a list of potentially harmful characters that can be used to break a PHP page? And, using regular expressions, how can I filter out the bad sequence of characters from all of my user input? For example.. to check if a email is valid I would use the below line: preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-...

Why can't javascript find and replace strings containing spaces in the url?

I'll start out by giving you the code I'm working on so that you can follow what I'm saying (sorry for the french, I realise all of you don't speak french but I'm making this website for a french-speaking school). I've edited out what I don't think is part of the problem (the actual file is 757 lines long!) photos.php <!DOCTYPE html PU...

Making an index for a search by PHP

How can you search only unique words with PHP such that I can learn the basics in making the search? I have had a few problems in making a multidimensional array for questions. My first unsuccessful attempt is the following. #1 $result = pg_query_params ( $dbconn, "SELECT question_id, body FROM questions", array () ); ...

Regular expression for date time format "MM/DD/YY HH:mm:ss AM/PM" in asp.net regular expression validator

Can anyone tell me the regular expression format for "MM/DD/YY HH:mm:ss AM/PM" to use it in a regular expression validator, in asp.net 2.0 ...

Regular expression to find URLs not inside a hyperlink

There's many regex's out there to match a URL. However, I'm trying to match URLs that do not appear anywhere within a <a> hyperlink tag (HREF, inner value, etc.). So NONE of the URLs in these should match: <a href="http://www.example.com/"&gt;something&lt;/a&gt; <a href="http://www.example.com/"&gt;http://www.example2.com&lt;/a&gt; <...

Regular Expressions - Filtering alphabetic and non-alphanumeric characters

I need to filter alphabetic and non alphanumeric characters from a string to make it an integer. What is the difference between the regular expression strings \w and \w* ? ...

RegularExpressionValidator bound Textbox never valid within DetailsView

Hello I have been having trouble with this for a while now. I have a bound textbox within a DetailsView that I have added a RegularExpressionValidator to. However after running the Web form I discovered that the value is never considered valid even when it should be. The field should only validate when the value is empty or exactly 3 upp...

Regular expression to check if a given password contains at least one number and one letter in c#?

Can anyone help me write a regular expression for checking if a password has at least one letter and one number in it? I have a requirement that users passwords must be alphanumeric and I want to be able to check for that using a regular expression. ...

REGEX Help for Coldfusion - In a URL, removing the ? And everything after

I'm looking for some REGEX help Given the following URL: http://news.cnet.com/8301-13924%5F3-10315534-64.html?part=rss&amp;subj=news&amp;tag=2547-1%5F3-0-20 What is the REGEX to obtain the following: http://news.cnet.com/8301-13924%5F3-10315534-64.html Thus removing the ? and everything after it Thanks, B ...

Regular Expression to check max of 2 digits,max of 4 alphabets in a alphanumeric string of length 6?

It should match all the following examples. aBCd22 a2b2CD 22aBcD ...

MYSQL:Looking for equivalent of Perl's "regex" =~ s/e/i/g => rigix in a MySQL Select

Can I match and replace a text pattern in a MYSQL select? EDIT For now it looks like the answer is: Can't be done, since you can't capture what was matched (from Eric's answer / comments). For now I will look into adding a lookup table. Simplified example: The MySQL table Coleridge holds many strings like: text ------------------...

Java Stringparsing with Regexp

I try to parse a String with a Regexp to get parameters out of it. As an example: String: "TestStringpart1 with second test part2" Result should be: String[] {"part1", "part2"} Regexp: "TestString(.*?) with second test (.*?)" My Testcode was: String regexp = "TestString(.*?) with second test (.*?)"; String res = "TestStringpart1 wi...

C# regex to match a string that doesn't contain a certain string?

This should be an easy one for the Regex experts out there... :) I want to match any string that does not contain the string "DontMatchThis". What's the regex? ...

Parsing Custom Tags with Ruby

I am trying to do pretty much the same thing as here, but in ruby: http://stackoverflow.com/questions/1201778/parsing-custom-tags-with-php ...

more succinct ruby regex

Is there are more succinct or Rubyesque way of writing this: if ( variable =~ /regex1/ || variable =~ /regex2/ || variable =~ /regex3/ ... ) end Namely, I'm hoping for something shorter, like: if ( variable =~ /regex1/,/regex2/,/regex3/ ) which I realize is not valid Ruby code, but figuring someone may know a more clever trick. ...