Regex to validate number and letter sequence
I want a regex to validate inputs of the form AABBAAA, where A is a a letter (a-z, A-Z) and B is a digit (0-9). All the As must be the same, and so must the Bs. ...
I want a regex to validate inputs of the form AABBAAA, where A is a a letter (a-z, A-Z) and B is a digit (0-9). All the As must be the same, and so must the Bs. ...
I'm thinking of presenting questions in the form of "here is your input: [foo], here are the capture groups/results: [bar]" (and maybe writing a small script to test their answers for my results). What are some good regex questions to ask? I need everything from beginner questions like "validate a 4 digit number" to "extract postal code...
I've tried this for a couple of hours and wasn't able to do this correctly; so I figured I'd post it here. Here's my problem. Given a string in java : "this is <a href='something'>one \nlink</a> some text <a href='fubar'>two \nlink</a> extra text" Now i want to strip out the link tag from this string using regular expressions - so th...
Consider the string 12345aaa. I want to use preg_split() on it so only the numeric part of it will be returned (i.e. 12345). How would I write the regex for it ? Thank you in advance ! ...
var ss= "<pre>aaaa\nbbb\nccc</pre>ddd"; var arr= ss.match( /<pre.*?<\/pre>/gm ); alert(arr); // null I'd want the PRE block be picked up, even though it spans over newline characters. I thought the 'm' flag does it. Does not. Found the answer here before posting. SInce I thought I knew JavaScript (read three books, worked hours) a...
I'm trying to write a regex pattern that will find numbers with two leading 00's in it in a string and replace it with a single 0. The problem is that I want to ignore numbers in parentheses and I can't figure out how to do this. For example, with the string: Somewhere 001 (2009) I want to return: Somewhere 01 (2009) I can search...
Given a string like: "The dog has a long tail, and it is RED!" What kind of JQUERY, JavaScript magic can be used to keep spaces to only 1 max? Goal: "The dog has a long tail, and it is RED!" thanks ...
How do you set the delimiter for a scanner to either ; or new line? I tried: Scanner.useDelimiter(Pattern.compile("(\n)|;")); But it doesn't work. ...
I need to write a split function in JavaScript that splits a string into an array, on a comma...but the comma must not be enclosed in quotation marks (' and "). Here are three examples and how the result (an array) should be: "peanut, butter, jelly" -> ["peanut", "butter", "jelly"] "peanut, 'butter, bread', 'jelly'" -> ["peanut", ...
Hi All, How can I remove email address from a string? And all other digits and special characters? Sample String can be "Hello world my # is 123 mail me @ [email protected]" Out put string should be "Hello world my is mail me" I googled this and found that I can use following regular expressions "[^A-Za-z0-9\\.\\@_\\-~#]+" but tha...
For example, I would like to count how many numbers are in a string using a regex like: [0-9] ...
Looking for a regex string that would match all alpha numeric character plus a few special ones that include + and -. Our current regex looks like this: ^[a-zA-Z0-9_,\.\-' ]+$ However, we need to also include the + and - as well so long as they are not surrounded by whitespace on either side. For example an A+ BC would match, but no...
This is specifically aimed at parsing hex bytes, but there's a more general question here. Suppose I have a regexp r e.g. \\s*([0-9A-Fa-f]{2})\\s* (optional spaces, 2 hex digits that I'm interested in, and optional spaces). If I want to parse a string s with this regexp such that: if s can be divided into a sequence of blocks that m...
The problem: I need to extract strings that are between $ characters from a block of text, but i'm a total n00b when it comes to regular expressions. For instance from this text: Li Europan lingues $es membres$ del sam familie. Lor $separat existentie es un$ myth. i would like to get an array consisting of: {'es membres', 'separat exis...
I'm writing a custom highlight animation with Scriptaculous that includes a CSS3 glow. I get the box-shadow style and need to split it at the rgba alpha value, then vary that value to get the shadow to fade. $('fresh').style.MozBoxShadow would return 0 0 20px rgba(163, 238, 71, 1.0) 1.0 is the alpha value. I need to split it so tha...
Hi, I need a PCRE(Perl Compatible Regular Expression) that will match all non-images(jpg,png,tiff) from a list of files. So I need something go in place of XXX # Perl while(<>){ chomp; if(/XXX/){ // non-image } } // PHP foreach($files as $file){ if(preg_match('/XXX/',$file){ // non-image } } I know it can be done using negation ...
Is there a way of generating a string that would match a regular expression in Ruby e.g. regex output ^\d{6}$ 875914 ^\d{3}-\w{2} 584-AS ...
When i write a regular expression like: m = /(s+).*?(l)[^l]*?(o+)/.exec( "this is hello to you" ) console.log( m ); I get a match object containing the following: { 0: "s is hello", 1: "s", 2: "l", 3: "o", index: 3, input: "this is hello to you" } I know the index of the entire match from the 'index' propert...
I want to write a function that allows users to match data based on a regexp, but I am concerned about sanitation of the user strings. I know with SQL queries you can use bind variables to avoid SQL injection attacks, but I am not sure if there's such a mechanism for regexps. I see that there's Regexp.escape, but I want to allow valid re...
Using Regex. I have this to find the words that end with those letters: \S+[abc]\b But I need all the words that has these letters in any position but not in the end. ...