regex

MySQL & Regex (checking for proper name capitalization)

Hi Everyone, I'm trying to check if a name has invalid characters, so far I've managed to get everything I need apart from checking for capitalization, I've tried using SELECT BINARY('jiLl') REGEXP('[[:upper:]]+'); but unfortunately that also flags properly formatted names, as in (Jack), is it possible to have the regex ignore the fir...

Quick string replace mod_rewrite question

all i want do is change my querystring from this result/?q=Southview+Guesthouse to this: result/?q=Southview-Guesthouse. I've done similar stuff with PHP but never mod_rewrite, has anyone got any ideas? Thanks. ...

Is it possible to show line numbers when using a regex in PHP?

I was just wondering if it is possible to have a regex that is searching for a string like '\bfunction\b' that will display the line number where it found the match? ...

How to preg_replace?

I want to replace something like http://www.somesite.com/videos/video23.mp4 with something like <some_my_tag>http://www.somesite.com/videos/video23.mp4&lt;/some_my_tag&gt;. How to do it in PHP? ...

Match both www.website.com and website.com with sql like

I have a table that contains a list of websites. I have a sql variable @url, I want to select all the rows where the website is equal to @url. However, if there is no subdomain I want to match www and the root domain. So, if @url='http://website.com' it should match both 'http://website.com' and 'http://www.website.com' I'm currentl...

replace every occurrence of 'line 2' with line_2 with regex

I'm parsing some text from an XML file which has sentences like "Subtract line 4 from line 1.", "Enter the amount from line 5" i want to replace all occurrences of line with line_ eg. Subtract line 4 from line 1 --> Subtract line_4 from line_1 Also, there are sentences like "Are the amounts on lines 4 and 8 the same?" and "Skip lines 9...

Matching quote contents

I am trying to remove quotes from a string. Example: "hello", how 'are "you" today' returns hello, how are "you" today I am using php preg_replace. I've got a couple of solutions at the moment: (\'|")(.*)\1 Problem with this is it matches all characters (including quotes) in the middle, so the result ($2) is hello", how 'are ...

Is there a RegExp.escape function in Javascript?

I just want to create a regular expression out of any possible string. var usersString = "Hello?!*`~World()[]"; var expression = new RegExp(RegExp.escape(usersString)) var matches = "Hello".match(expression); Is there a built in method for that? If not, what do people use? Ruby has RegExp.escape. I don't feel like I'd need to write...

Regular Expression Help

Hi All I need help in regular expressions, match and replace pattens. I am working on rates. my rates can be like 345.00 456 2345.90 341.34 I have to check if the rate ends in 9, if not i have to end the rate with 9 and a $ symbol. The rates after running the rule should become $349.00 $459.00 $2349.00 $339.00 I am storing the r...

Regular Expression for number

Hi. Please help me to make a Regular Expression with following rule - Max number can be 9999.99 Should be non-negative Can not be 0, but 0.01 and so on is valid So, I need a non negative number between 0.01-9999.99 ...

.Net Regex that Matches Strings With Any non-ASCII char in it

Looking for some black magic that will match any string with "weird" characters in it. Standard ASCII characters are fine. Everything else isn't. This is for sanitizing various web forms. ...

how can i get a regular expression to match whole words like grand and not match mygrandma.

how can i get a regular expression to match whole words like grand and not match mygrandma. for example, i wish to replace "grand" with "total", so "the grand sum is 100" should become "the total sum is 100". however "my grandma likes apples" should not become "my totalma likes apples". ...

how remove special characters from the end of every word in a string?

i want it match only the end of every word example: "i am test-ing., i am test.ing-, i am_, test_ing," output should be: "i am test-ing i am test.ing i am test_ing" ...

Regex question using IIS7's URL Rewrite module

I'm using URL Rewrite module in IIS7 and using the User Friendly URL Rule template. I'm trying to get URLs like: Something/param1/something/param2/something/param3/something/something2/ etc.etc. to rewrite to SomethingEnd.aspx?param1=something&param2=something&param3=something/something2& etc.etc. Using the templates, it automatic...

PHP regex use same letter

Im trying to do a regex where I can find all html tags, but for each one, each opening and closing tag must be the same. Heres what I mean: (Yes I only want max 3 letters) preg_match_all("/\<[a-z]{1,3}\>(.*?)\<\/[a-z]{1,3}\>/", $string, $matches); Where the 2 [a-z]{1,3} are, I want those to be the same, so it doesn't match <b> with <\...

Movable Type: Change URL using regex replace

Hi, In my <mt:EntryBody> text I have few urls which I want to change the pointing address. http://www.myblog.com/blog/content/fruit/apple.html to http://www.myblog.com/blog/apple/ In this case word "fruit" and "apple" would be the variable. I would like to use regex_replace modifier to change every URL in EntryBody. How would I w...

Regular Expression Help - .Net

SearchPattern = (?<price1>[0-9]+)(?<price2>[9]?)+(.)(?<price3>[9]{2}) zero or more matches of 0-9 numbers followed by one or more 9 followed by 2 optional digits after the dot. I did not understand, what does price1, price2, price3 means? can someone help me here. ReplacementPattern = (?<price1>[0-9]+)(?<price2>[0-9]{1})+(.)(?<price3...

Regex to extract info from SQL query

As I am new for the REGEX i am not able to solve below thing. And please share some parser related links so the i can learn it. I am facing problem in solving int below SQL statement. Its more line added to the previous INPUT. Please help me to slove this. DECLARE numerator NUMBER; BEGIN SELECT x, y INTO numerator, denominator FROM...

Can search(r'(ab)+', "ababababab") match all the characters in python

I found that findall(r'(ab)+', "ababababab") can only match the ["ab"] >>> re.findall(r'(ab)+', "ababababab") ['ab'] i just know that using r'(?:ab)+' can match all the characters >>> re.findall(r'(?:ab)+', "ababababab") ['ababababab'] Why does this happen? ...

Parsing a blank / whitespace with RegexParsers

What is the problem with parsing the blank/whitespace? scala> object BlankParser extends RegexParsers { def blank: Parser[Any] = " " def foo: Parser[Any] = "foo" } defined module BlankParser scala> BlankParser.parseAll(BlankParser.foo, "foo") res15: BlankParser.ParseResult[Any] = [1.4] parsed: foo scala> Blank...