regex

How do I click on a specific button using cucumber/webrat when the name of the button starts with the same word?

I have the following html with multiple inputs: <input type="submit" value="Save and close" name="commit"/> <input type="submit" value="Save" name="commit"/> and would like to use cucumber to test clicking on the "Save" button. However, when I do this in a cucumber test: When I press "Save" it clicks on the "Save and close" button,...

storing regexkitlite matches by by the group instead of the occurance

Hello, I'm not sure if there is away to do this but it doesnt hurt to ask i'm using regexkitlite to create a iPhone app. Im specifically using the Regex lib to parse some html. My question is in a regular expression such as @"<a href=([^>]*)>([^>]*) - " each match in between the brackets can be placed in an array using NSString *r...

Url Matching using Gruber's regex in PHP

how do I get the regex mentioned in this article working with preg_match in php? <?php preg_match("\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))/i", $text, $matches); print_r($matches); ?> Using the code above I get the following error: Warning: preg_match() [function.preg-match]: Delimiter must not be alphanume...

Replacing text in Python

I've been looking at the re documentation and at other questions but I keep running into trouble with regex. I need to take what ever is in the [tag] off of the string. string = "Article Name [Tag Name]" #and I want to go to string = "Article Name" I'd really appreciate it if anyone could help. ...

regular express : how to exclude multiple character groups?

I have a set of urls : /products /categories /customers Now say a customers is named john, and I want to help john to reach his own account page with a shorter url: before : /customers/john after : /john (suppose customer names are unique) I'm trying to figure out a proper regex dispatcher so all customers can have ...

Help Hacking Gruber's Liberal URL Regex

I've taken the Liberal URL Regex from Daring Fireball, merged it with some of Alan Storm improvements and hacked my way into fixing some bugs like support for IDN chars inside parentheses. This is what I've: /(?:[\w-]+:\/\/?|www[.])[^\s()<>]+(?:(?:\([^\s()<>]*\)[^\s()<>]*)+|[^[:punct:]\s]|\/)/ However I've encountered a bug that I'm n...

need a regular expression without space and minimun 5 characters, max 20

hi, I need a regular expression which accepts the alphabets UPPER CASE,lower case and digits minimum character is 5 and maximum character is 20. This is my current Reg Ex. ^[A-Za-z\d]{5,20}$ The issue that i am facing with the current Regular expression is, if i enter 5 spaces it accepts. so i want the user to enter password withou...

Regular Expression: Start from second one

I want to find the second <BR> tag and to start the search from there. How can i do it using regular expressions? <BR>like <BR>Abdurrahman<BR><SMALL>Fathers Name</SMALL> ...

How can I check if a Perl string contains letters?

In Perl, what regex should I use to find if a string of characters has letters or not? Example of a string used: Thu Jan 1 05:30:00 1970 Would this be fine? if ($l =~ /[a-zA-Z]/) { print "string "; } else { print "number "; } ...

regexp_replace in database to reverse a numeric string and insert a period between each digit

I have database where one column contains numbers. 3 example values: 1111111555 2222222555 3333333555 which I need to reverse and put a dot between each digit. i.e. the result for each of the examples above would be: 5.5.5.1.1.1.1.1.1.1 5.5.5.2.2.2.2.2.2.2 5.5.5.3.3.3.3.3.3.3 respectively. I then need to update another column wi...

How do I search through regex matches in Python?

Hi, I need to try a string against multiple (exclusive - meaning a string that matches one of them can't match any of the other) regexes, and execute a different piece of code depending on which one it matches. What I have currently is: m = firstre.match(str) if m: # Do something m = secondre.match(str) if m: # Do something el...

optimizing Pretty URLs in .htaccess

This is the code I use, <IfModule mod_rewrite.c> RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([^/]+)/?([^/]+) index.php?user=$1&do=$2 [L] </IfModule> if i give it abcd/1234 it will capture abcd first then 1234 as the second variable. But if the url was abcd/ or abcd the first capture stays th...

How can I check if a string contains a specific charater in Regex?

How can I check if a string contains at any position one or more '/' character(s) in Regex? Thanks. ...

Help in migrating from ISAPI_Rewrite to IIS7 URL Rewriting

Hi, I've this ISAPI_Rewrite rule: RewriteRule /([^/.?]+) /sc.asp?p=$1 [I,L] This rule should rewrite Urls like: /some-article /article2 and shouldn't rewrite Urls like: /home.asp /admin (because there's a directory named admin) /admin/ /sites/gutterman It works great in ISAPI_Rewrite Yesterday I bought ...

JavaScript/jQuery - grabbing an integer from an element's id

From the following markup. <div id="my-div"> <a href="#" id="link-1">Somewhere</a> <a href="#" id="link-2">Somewhere else</a> </div> What are some options, using jQuery selectors and JavaScript for grabbing the integer in the ids? For example. $("#my-div a").click(function(){ $(this).id // ... somehow grab n from "link-...

Regular Expression for file path validation

I can't seem to find a Regular Expression for javascript that will test for the following cases: c:\temp D:\directoryname\testing\ \john-desktop\tempdir\ You can see what I'm going for. I just need it to validate a file path. But it seems like all the expressions I've found, don't work for javascript. Thank you in advance. John ...

Only match regular expression in c# string

Hi, I am not too good with regular expressions so this might be an obvious question. I want my expression to match if a certain number of characters are found and fail if any extra characters are present. For example if I have a string that should have 4 digits the following should be true. 1234 - match ab1234cd - does not match 0123...

Java regular expression OR operator

This may be a dumb question, but I couldn't find it anywhere: How can I use the java OR regular expression operator (|) without parentheses? e.g: Tel|Phone|Fax ...

Saving a .php file and saving the includes too (possibly)

The setup: I have a standard .php file (index.php) that contains two includes, one for header (header.php) and one for footer (footer.php). The index.php file looks like this: index.php <?php include header.php; ?> <h2>Hello</h2> <p class="editable">Lorem ipsum dolar doo dah day</p> <?php include footer.php; ?> header.php like thi...

Retrieve the text between A tags

I'm trying to retrieve link text from an HTML file. Each of the link have a specific class applied to them, but the urls are different. I have the following: ... <a class="fetch-me" href="products/1">Find ME!!!</a> ... <a class="fetch-me" href="products/2">Me too!</a> ... I am using the following PHP code, but always getting more th...