regex

Password Regular Expression is not working with RadInputManager?

I am using Teleriks RadInputManager control to check that a password is between 7 and 16 characters and contains at least 1 numeric and 1 special character, but when I type something that I know fits the expression, validation fails, so I believe my regular expression is wrong. Here is the expression I am using: /^(?=.{7,16}$)\D+\d/ ...

Confused on why this regular expression does not work?

/^(?=.*\d)(?=.*[!@&.$#]).{7,16}$/ It should allow between 7 and 16 characters and contain at least 1 numeric character and 1 special character and can't start with a number. I tried testing it but it does not work? ...

Tools that turn regular phrases into regular expressions?

I know there are a lot of tools that allow you to create regular expressions and test regular phrases against them, but is there a tool that allows you to type just a regular phrase or word, etc and it will generate the regular expression for you. For example, typing: xyz555.. would generate the correct regular expression. It may not ...

Simple syntax question

Hey everyone, First off, sorry for my noob-ness. Believe me when i say ive been rtfm'ing. Im not lazy, im just dumb (apparently). On the bright side, this could earn someone some easy points here. I'm trying to do a match/replace with a pattern that contains special characters, and running into syntax errors in a Flex 3 app. I just wan...

Javascript regular expression

text = 'ticket number #1234 and #8976 '; r = /#(\d+)/g; var match = r.exec(text); log(match); // ["#1234", "1234"] In the above case I would like to capture both 1234 and 8976. How do I do that. Also the sentence can have any number of '#' followed by integers. So the solution should not hard not be hard coded assuming that there wil...

How can I capture the group of digits at the end of a string in Perl?

I'm trying to capture the last digits in this line in a regex group: The input: 9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 54654 My pattern: /Power_On_Hours.+Always\s.+([0-9]{1,5})/ I just can't seem to get it to capture "54654", it's returning undef :( ...

How do I write a Perl regular expression that will match a string with only these characters?

I am pretty new to regular expressions. I want to write a regular expression which validates whether the given string has only certain characters. If the string has any other characters than these it should not be matched. The characters I want are: & ' : , / - ( ) . # " ; A-Z a-z 0-9 ...

How to match a comment unless it's in a quoted string?

So I have some string: //Blah blah blach // sdfkjlasdf "Another //thing" And I'm using java regex to replace all the lines that have double slashes like so: theString = Pattern.compile("//(.*?)\\n", Pattern.DOTALL).matcher(theString).replaceAll(""); And it works for the most part, but the problem is it removes all the occurrences a...

Regex for IPv4 Routable address only

What is a regex that can find a routable IPv4 addresses only? EG, does not match 192.0.2.1/24, 127.0.0.1, etc. Google seems to only find the all too common 'is an ip address' regex. ...

Shorter way to express regular expression matching a space or " "

I have a regular expression that is getting some information from a string. I need the values on both sides of either a space or a nbsp. Problem is that I believe the only way I can specify either or is with groups and bar. Is there a more concise or readable way to do this? There has to be! Using Regex in C# Regex: (\d)(?:(?:\s)|(?:&...

Perl Regular Expressions to match a MD5 Hash?

Recently programming in PHP, I thought I had a working Perl regular expression but when I checked it against what I wanted, it didn't work. What is the right expression to check if something is a MD5 has (32 digit hexadecimal of a-z and 0-9). Currently, I have /^[a-z0-9]{32}$/i ...

Java regex help

Can somebody please show me how to do a Java regex that takes in a string and returns a string with all characters removed BUT a-z and 0-9? I.e. given a string a%4aj231*9.+ it will return a4aj2319 thanks. ...

Capturing part of a url

Hi, I'm having some difficulty writing a regular expression. My input will be a url, looking like this: http://www.a.com/farms/important-stuff-here#ignorable-stuff I wanted to capture (some-stuff-here), which is everything between the last forward slash, and the first # sign (or just the ending, if the # sign extra content does not ex...

Is it feasible to write a regex that can validate simple math?

I’m using a commercial application that has an option to use RegEx to validate field formatting. Normally this works quite well. However, today I’m faced with validating the following strings: quoted alphanumeric codes with simple arithmetic operators (+-/*). Apparently the issue is sometimes users add additional spaces (e.g. “ FLR0...

Boost regular expressions

Does anyone know of any good tutorials on regular expressions using boost? I have been searching for a decent one, but it seems most are for people who know a little about regular expressions ...

replace character (space with  ) across whole webpage using javascript/jQuery

Hi, So I figured out that the replace function, that finds all single-letter "words" (prepositions and conjunction, etc.) and replace the space after them with a   to prevent leaving these characters at the end of line, should be something like myString.replace(/\s\w(?=\s)/,"$1 ") Now how do I apply it to all text on a webp...

Java Regex, capturing groups with comma separated values.

InputString: A soldier may have bruises , wounds , marks , dislocations or other Injuries that hurt him . ExpectedOutput: bruises wounds marks dislocations Injuries Generalized Pattern Tried: ".[\s]?(\w+?)"+ // bruises. "(?:(\s)?,(\s)?(\w+?))*"+ // wounds marks dislocations "[\s]?(?:or|a...

Regex two given words in one sentence

Hello. I want to get a regex which can tell if two given words are in one sentence (word order matters). The problem is that I can have a contraction in a sentence, so the period doesn't indicate that there's the end of the sentence. The part of regex which indicates the end of the sentence is \.(\s+[A-Z]|\s*$) Could someone help me to ...

How-to strip email and phone numbers from html input ?

How-to strip email and phone numbers from html input ? Before: "please contact me at [email protected] or email[at]email.com or by phone at 555 555 555" After: "please contact me at [Replacement] or [Replacement] or by phone at [Replacement]" ...

Using RegEx Replace function in C# ASP.NET

How do I solve the problem below? I'm creating a simple content management system, where there is a HTML template with specific markup that denotes where content should be: <html><head></head><body><!-- #Editable "Body1" --><p>etc etc</p><!-- #Editable "Extra" --></body></html> Separate from this, there is content in a database fiel...