regex

Zend RegEx Validator error message issue

Hello, I'm validating a text field in my form as follows: $name = new Zend_Form_Element_Text('name'); $name->setLabel('First Name:') ->setRequired(true) ->addFilter(new Zend_Filter_StringTrim()) ->addValidator('regex',true,array('/^[(a-zA-Z0-9)]+$/')) ->addErrorMessage('Please enter a valid first name'); Wha...

RegEx expression to find a href links and add NoFollow to them

I am trying to write a RegEx rule to find all a href HTML links on my webpage and add a 'rel="nofollow"' to them. However, I have a list of URLs that must be excluded (for exmaple, ANY (wildcards) internal link (eg. pokerdiy.com) - so that any internal link that has my domain name in is excluded from this. I want to be able to specify e...

Javascript regular expression pattern (.+?)

Deal experts, I am kinda new to this Regex thing. When I was analyzing some codes, I frequently come across the pattern .+? or (.+?) I can't seem to find the meaning of this pattern using my noobish deductive reasoning. ...

Regular expression to match last item without delimiter

I have a string of names like this "J. Smith; B. Jones; O. Henry" I can match all but the last name with \w+.*?; Is there a regular expression that will match all the names, including the last one? ...

R regex to validate user input is correct.

I'm trying to practice writing better code, so I wanted to validate my input sequence with regex to make sure that the first thing I get is a single letter A to H only, and the second is a number 1 to 12 only. I'm new to regex and not sure what the expression should look like. I'm also not sure what type of error R would throw if this ...

PHP: How do I get the string indexes of a preg_match_all?

Hi all, let's say I have two regexp's, /eat (apple|pear)/ /I like/ and text "I like to eat apples on a rainy day, but on sunny days, I like to eat pears." What I want is to get the following indexes with preg_match: match: 0,5 (I like) match: 10,19 (eat apples) match: 57,62 (I like) match: 67,75 (eat pears) Is there any way to ...

Mixing regular expression and other conditional expression in a bash if statement

I can't get around this for quite sometime now. As I read along manuals and tutorials I'm getting more confused. I want an if statement with the following logic: if [ -n $drupal_version ] && [[ "$drupal_version" =~ DRUPAL-[6-9]-[1-9][1-9] ]]; then but I can't get it to work properly. When the script is evaluated using the "bash -x .....

Backslash escaping in RegularExpressionValidator

I need to ensure that the input value contains at least one dot, so i use the following: <asp:RegularExpressionValidator runat="server" ControlToValidate="MyInput" Text="*" ErrorMessage="must contain at least one dot" ValidationExpression="\.+" /> And that doesn't work. By inspecting the page source i can see that ASP.NET escapes the ...

Regex-expression with danish characters

I'm currently trying to wrap my head around regex, I have a validation snippet that tests an input box against a regex-expression: $.validator.addMethod("customerName", function(value, element){ return (/^[a-zA-Z]*$/).test(value); }, "Some text"); That works well, but when I try to add a space and some special danish characters, it do...

asp.net regular expression not working as expected

Hi, I have a textbox and a regular expression validator applied to it. I want to make sure that the only allowed string inputted into the textbox are "Anything Entered" or "Something Else" or "Another String" otherwise I want an error to be displayed. This is the regular expression I have so far: ValidationExpression="(^Anything Enter...

regular expression in fbjs

http://jamienay.com/2009/12/a-better-postal-zip-code-validation-method-for-cakephp-1-2/ i want to do the validation for zip code in FBJS for us and canada. suggest some script or how to convert the about php code(in link) to fbjs ...

Substitution till the end of the line in bash

Hi, I have a huge text file with lots of lines like: asdasdasdaasdasd_DATA_3424223423423423 gsgsdgsgs_DATA_6846343636 ..... I would like to do, for each line, to substitute from DATA_ .. to the end, with just empty space so I would get: asdasdasdaasdasd_DATA_ gsgsdgsgs_DATA_ ..... I know that you can do something similar with: ...

Regular expression question

I have some text like this: dagGeneralCodes$_ctl1$_ctl0 Some text dagGeneralCodes$_ctl2$_ctl0 Some text dagGeneralCodes$_ctl3$_ctl0 Some text dagGeneralCodes$_ctl4$_ctl0 Some text I want to create a regular expression that extracts the last occurrence of dagGeneralCodes$_ctl[number]$_ctl0 from the text above. the result should ...

Matching innermost braces with regex or strpos?

I have a sort of mini parsing syntax I made up to help me streamline my view code in cakephp. Basically I have created a table helper which, when given a dataset and (optionally) a set of options for how to format the data will render out a table, as opposed to me looping though the data and editing it manually. It allows the user to be...

Parse and replace string using Regex

Hi, i have various strings that look like that: $(gateway.jms.jndi.ic.url,0,tibjmsnaming, tcp)/topic/$(gateway.destination.prefix)$(gateway.StatusTopicName),$(gateway.jms.jndi.ic.username),$(gateway.jms.jndi.ic.password),abinding,tBinding i'm trying to figure out a way to extract the $(...) sections and replace them with some other s...

AS3 : RegExp exec method in loop problem

Hi everyone, I need some help about RegExp in AS3. I have a simple pattern : patternYouTube = new RegExp ( "v(?:\/|=)([A-Z0-9_-]+)", "gi" ); This pattern is looking for the youTube id video. For example : var tmpUrl : String; var result : Object; var toto : Array = new Array(); toto = ["http://www.youtube.com/v/J-vCxmjCm-8&am...

php preg_split last occurrence of character

Looking for some help! I need to split a string at the last occurrence of a space... e.g. "Great Neck NY" I need to split it so I have "Great Neck" and "NY" I haven't had a problem using preg_split with basic stuff but I'm stumped trying to figure out how to tell it only to split at the last occurrence! Any help would be appreciate...

Javascript regular expressions problem

Hello! I am creating a small Yahtzee game and i have run into some regex problems. I need to verify certain criteria to see if they are met. The fields one to six is very straight forward the problem comes after that. Like trying to create a regex that matches the ladder. The Straight should contain one of the following characters 1-5. ...

Regular expressions in URL Rewrite Module for IIS7

I have following rewrite rule to append .aspx extension if url has no extension. <rule name="SimpleRewrite" stopProcessing="true"> <match url="^(.*(?&lt;=/)([^/.]*))$" /> <action type="Rewrite" url="{R:1}.aspx" /> </rule> However the rule is not working: Error HTTP 500.52 - URL Rewrite Module Error. The ex...

String format or REGEX.

I need an simple way to check whether a string that is sent to my function is of the form: (x + n)(x + m) //the +'s can be minus' //n and m represent a double //x represents the char 'x' Is there a simple string format that I can use to check that this is the form. As opposed to checking each character singularly. The whitespace wil...