regex

Regex to match a word NOT within a specific number of words of another word

Hope I can explain this one. I've got a regex for matching two words near each other. For example, if I want to find the word "account" and "number" within 5 words of each other: \baccount\W+(?:\w+\W+){1,6}?number\b This works perfectly. Now I need to find a way to search for a word as long as it is NOT within 2 words of another wor...

Regex (or better) method to de|unconcatenate a string

I'm currently attempting to present several enum's to the UI, albeit in a more friendly manner than a concatenated string. public enum StoreMethod { // Insert To Front InsertToFront, // Insert to End InsertToEnd, // Overwrite Existing OverwriteExisting, // Throw Exception If Exists ThrowExceptionIfExists } If I...

Can't escape the backslash with regex ?

I'm using the following regex ^[a-zA-Z0-9\',!;\?\$\^:\\\/`\|~&\" @#%\*\{}\(\)_\+\.\s=-]{1,1000}$ I know it's ugly, but so far it serves its purpose other than the backslash not being allowed as I think it should because it's escaped, I also tried \\ instead of \\\ but same results. Any ideas? ...

Js RegExp every other character

I have random strings that are similar to this: 2d4hk8x37m or whatever. I need to split it at every other character. To split it at every character its simply: '2d4hk8x37m'.split(''); But i need every other character so the array would be like this: ['2d', '4h', 'k8', 'x3', '7m'] Your help is appreciated. Thanks! ...

Regular expression for commonly understandable number formats

What is a regex that can match a generally understandable number? (the simpler the better) for example, it should match: 10 10.0 10.00 3.3333 123456 100,000 1,234,567 33,456.22 -2.2 .2 -.2 +.2 0.2 .20 should not match: 33,33.1 1.2.3 100,000,000000 ...

Regex: word boundary but for white space, beginning of line or end of line only

I am looking for some word boundary to cover those 3 cases: beginning of string end of string white space Is there something like that since \b covers also -,/ etc.? Would like to replace \b in this pattern by something described above: (\b\d*\sx\s|\b\d*x|\b) ...

PHP Regex Any Character

The . character in a php regex accepts all characters, except a newline. What can I use to accept ALL characters, including newlines? ...

notepad++ regular expressions to convert lines for SPSS syntax editor

Hi People, I am curently busy with bulding a synthax document in SPSS and have a column of variable strings that consists of approximately 40 lines (it will be much much more in coming week). SPSS has a nice way of creating it (can be seen here :) http://vault.hanover.edu/~altermattw/methods/stats/reliable/reliability-1.html) but it can...

What is the regex for *abc?

I am trying to use Regex to find out if a string matches *abc - in other words, it starts with anything but finishes with "abc"? What is the regex expression for this? I tried *abc but "Regex.Matches" returns true for xxabcd, which is not what I want. ...

PHP Regex No Backslash

So I hadn't done any regexps for a while, so I thought I'd brush up on my memory. I'm trying to convert a string like a*b*c into a<b>b</b>c. I've already gotten that working, but now I want to keep a string like a\*b\*c from turning into a\<b>b\</b>c, but rather, into a*b*c. Here's the code I'm using now: $string = preg_replace("/\...

Regex to get text BETWEEN two characters.

PLEASE READ CAREFULLY: This is a bit unusual and you will be tempted to say things like "that isn't how to use a regex" or "dude, just use String.SubString()," Etc... I have a need to write a regex (to use a pre-existing method) that will match text BETWEEN curly braces, BUT NOT the curly braces themselves. For Example: "{MatchThisTex...

A regex to match anything that doesn't start with a certain string.

I'm writing a mod_rewrite rule and would like a hand making it do what I want. Basically I want the following cases to work: request | Redirect to --------------------- cheese | /?page=cheese abc123 | /?page=abc123 abc/def | /?page=abc/def a/b/c/d | /?page=a/b/c/d (Any alphanumeric plus . - / and _ redirected) With two special cas...

Parsing HTML passed in from JavaScript routine - in IE it comes back with Html tags capitalised - need work around!

Hi, Ultimately my application is pattern matching based on a text selection within a web browser, generating regEx code so that a portion of a page can be revisited and read anagrammatically. I'm currently pulling a portion of the text by walking up the dom and then returning innerHtml. The issue that I have is the text value of the i...

URL Validation?

Does anyone know an up to date regular expression for validating URLs? I found a few on Google but they all allowed junk URL's i.e (www.google_com) when testing. My regular expression knowledge is not so vast, so I would hate to put something together that would fail under pressure. Thanks. ...

python regex finding all groups of words.

Here is what I have so far text = "Hello world. It is a nice day today. Don't you think so?" re.findall('\w{3,}\s{1,}\w{3,}',text) #['Hello world', 'nice day', 'you think'] The desired output would be ['Hello world', 'nice day', 'day today', 'today Don't', 'Don't you', 'you think'] Can this be done with a simple regex pattern? ...

php preg replace :: regex

Hi there, If I have a string that looks like my name is {your name here} and I am from {country}. I am trying to use preg_replace to remove the {content} so the string ends up as my name is and I am from . But I can not work out the regex for the pattern. Can someone please help me out? my name is and I am from . is simply a sample ...

Javascript Regex: Get everything from inside / tags

What I want From the above subject I want to get search=adam and page=content and message=2. Subject: /search=adam/page=content/message=2 What I have tried so far (\/)+search+\=+(.*)\/ But this is not good because sometimes the subject ends with nothing and in my case there must be a / (\/)+search+\=+(.*?)+(\/*?) But th...

Can one use named backreference's in Apache mod_rewrite

All, I've come across an interesting little quirk in one of my RewriteRules, which I wanted to resolve by the use of named back references. However from what I can see, this is not possible in Apache's mod_rewrite. I have two incoming urls, each containing a key variable, which need to be rewritten to the same underlying framework acti...

Javascript: Change specific part of the hash

So for example I have: http://www.example.com/index.php#/parameter1=one/parameter2=two/ Now how should I update only the parameter1's value? ...

Regex to parse functions with arbitrary depth

I'm parsing a simple language (Excel formulas) for the functions contained within. A function name must start with any letter, followed by any number of letters/numbers, and ending with an open paren (no spaces in between). For example MyFunc(. The function can contain any arguments, including other functions and must end with a close ...