regex

Good free tools for learning/testing Regular Expressions

Are there any free tools/resources for testing / learning regular expressions, like RegexBuddy? ...

regex int or float

Hi, My regex won't work on single digit number /^[0-9]{1,7}\.?[0-9]{1,2}$/ I need it to work on unsigned numbers: 1 (single digit numbers, without fractions) - currently it fails on them 1.0; 0.31 (floating point numbers) Number before fraction can be 1-7 digits; after fraction 1-2 digits. Thanks you! ...

Best practices for localization

HI there, i am localizing my application. i have some REG EX(for english) expression for client side validation.if i want to localize for non-english ,what is the best approach should i have REG-Ex for all languages chosen for localization comments\suggestions appreciated. Thanks DEE ...

Make space to dash with regexp

I've got a sinatra app where I plan to make a friedly-urls on the fly. I've got a function with a regexp that looks like this, but it won't turn 'spaces' into 'dashes', ' ' to '-'. def self.make_slug(title) title.downcase.gsub(/ /, '-').gsub(/[^a-z0-9_]/, '').squeeze('-') end Thanks in advance! Update Now I'm also trying to change...

Regular expression identifier and separator using ':' symbol

I want to separate my string between two ':' characters. For example, if the input is "mypage-google-wax:press:-happy", then I want "press" out. It can be assumed that the input doesn't contain any numeric characters. ...

Get total number of matches for a regex via standard unix command

Let's say that I want to count the number of "o" characters in the text oooasdfa oasoasgo My first thought was to do grep -c o, but this returns 2, because grep returns the number of matching lines, not the total number of matches. Is there a flag I can use with grep to change this? Or perhaps I should be using awk, or some other comm...

Which is faster, XPath or Regexp?

I am making an add-on for firefox and it loads a html page using ajax (add-on has it's XUL panel). Now at this point, i did not search for a ways of creating a document object and placing the ajax request contents into it and then using xPath to find what i need. Instead i am loading the contents and parsing it as text with regular expr...

Match a PHP class with a Regular Expression

I wanna catch Php classes from a file: class a { function test() { } } class b extends a { function test() { } } and the result matches must be class a { function test() { } } and class b extends a { function test() { } } ...

Regex to match last occurrence

Hey there, as i don't want to spend another hour googling forthe right regex: I want to remove the last backslash of a given string with gsub: "C:\Program Files\".gsub(fancy_regex_here, '') # => "C:\Program Files" Thanks in advance for any help ...

Python regex string to list of words (including words with hyphens)

I would like to parse a string to obtain a list including all words (hyphenated words, too). Current code is: s = '-this is. A - sentence;one-word' re.compile("\W+",re.UNICODE).split(s) returns: ['', 'this', 'is', 'A', 'sentence', 'one', 'word'] and I would like it to return: ['', 'this', 'is', 'A', 'sentence', 'one-word'] ...

Help wanted with regular expression

I would like to parse a mailer to-string which could consist of the following examples separated with a comma (,): First name <[email protected]> "first name" <[email protected]> <[email protected]> [email protected] I would like to make an array with an entry for each element with two sub-entries: [name] and [email]. I've been strug...

Change syntax using regular expression

I have some inherited legacy language code snippets stored in a database table that I need to transform to a SQL like syntax so it can be used more effectively. For example, one of the snippets is of the form keyword = [a,b,c,x:y,d,e,f,p:q] to indicate either discrete comma separate values or a range of colon-delimited values How c...

Split html row into string array

I have data in an html file, in a table: <table> <tr><td>001</td><td>MC Hammer</td><td>Can't Touch This</td></tr> <tr><td>002</td><td>Tone Loc</td><td>Funky Cold Medina</td></tr> <tr><td>003</td><td>Funkdoobiest</td><td>Bow Wow Wow</td></tr> </table> How do I split a single row into an array or list? string row = streamRe...

Regular Expressions in ColdFusion

Possible Duplicate: How do I match a string that does not contain X with ColdFusion regular expressions? In ColdFusion version 8, I am building a validation table that contains regular expressions. Using a regular expression, how do you say: <cfif FIND("X",myString)> <cfset returnValue=0> <cfelse> <cfset returnValue=1> ...

Using a Regex Back-reference In a Repetition Construct ({N})

I need to match a string that is prefixed with an acceptable length for that string. For example, {3}abc would match, because the abc part is 3 characters long. {3}abcd would fail because abcd is not 3 characters long. I would use ^\{(\d+)\}.{\1}$ (capture a number N inside curly braces, then any character N times) but it appears that ...

Powershell -like expression from a SQL LIKE expression

I have a table in my database that includes some columns that are used for LIKE expressions in SQL. The process I'm working with uses those expressions to exclude certain SQL objects from processing. I'm now putting similar code in Powershell, but I'd like to keep the columns consistent. I'm going to need to do something along the lines...

Authenticating if a Facebook account exists - don't want to go through FB login

Hi, I'd like to figure out a way to authenticate a facebook account on a form, without having to go into facebook login and whatnot. So my question, is there anyway to check, I was thinking maybe the markup with regex, where I could check to see if a facebook count exists, and if so do something. Thanks for the suggestions. ...

Using Embedly api regex in c#

Embedly has a great regex generator with which you can use to verfiy the correctnes of services urls(http://api.embed.ly/tools/generator). It generates javascript regexes, but unfortunately it does not generate c# regex expressions. As far as I know though, c# uses the same ECMA regex definition, and I should therefore be able to use the...

Merging two strings of key=value pairs in JavaScript

I'm trying to come up with an efficient way to overwrite 2 strings that look like this: str1 = "width=800,height=600,resizable=no,titlebar=no"; str2 = "width=100,height=100"; In the above example, str2 should overwrite str1 to produce str3: str3 = "width=100,height=100,resizable=no,titlebar=no"; In my tests, I turned str2 into an a...

Is regex a good way to test a url

I'm trying to test the validity of a url entered with php5. I thought of using regex, but assuming that it works correctly all the time, it only solves the problem of the url being syntactically valid. It doesn't tell me anything about the url being correct or working. I'm trying to find another solution to do both if possible. Or is i...