regex

Help With Particular Regular Expression - Not Containing Some String

How do I say, in regular expressions: Any portion of a string beginning with a capital letter, containing at least one space character, not containing the string " _ " (space underscore space), and ending with the string "!!!" (without the quotes)? I am having trouble with the "not containing" part. Here is what I have so far: [A-Z]....

[C] check input for UTF-8, count characters, use regular expressions

Hi, I want to write a C-programm that gets some strings from input. I want to save them in a MySQL database. For security I would like to check, if the input is a (possible) UTF-8 string, count the number of characters and also use some regular expressions to validate the input. So my question is the following: Is there a library that ...

Regular expression to match characters in a string, excluding matches within HTML anchor elements

Consider this blob of text: @" I want to match the word 'highlight' in a string. But I don't want to match highlight when it is contained in an HTML anchor element. The expression should not match highlight in the following text: <a href='#'>highlight</a> " Here's what the output should look like (matches are in bold): I want to ...

preg_replace conditional replacement with different string

I know there's a if/then in the matching of regular expressions, but is there one in the replace? ie. I want to do in one regex "I have Foo Bars under $5 for sale" to be "Foo Bars~$5" "I have Foo Bars for sale" to become "Foo Bars" and NOT "Foo Bars~" I have an expression a bit like this at the moment: preg_replace("/(([A-Z]...

MySQL REGEXP (problem with params order)

Query: SELECT * FROM (test) test_label WHERE REGEXP "AA(.*)BB" OR test_label REGEXP "BB(.*)AA"** Database (string): 1. AA BB 100 2. AA BB 200 3. BB AA 300 4. BB CC 100 5. AA CC 300 This query returns rows: 1, 2 and 3. How: Combine this expression into one (but - i want it with one REGEXP but not with OR - if it is possible it mus...

python regex question

I want to match certain symbols only when they are not prefixed by specific characters. For instance, match "))))))))))" when it is not preceded by "x". Need some advices. My current expession is (?<!x|X|:|=|\\1)([\|()\[\]])+ which does not work. [EDIT] Rephrase my question ...

regular expression match php

Hi, I need to do a regular expression match in php . the case is that . 2 digits before decimal and 2 digits after decimal. the problem is that it may and may not have decimal and after decimal digits . how do i write a expression for this ? ...

PHP and Regex Problem

Possible Duplicate: Best way to parse bbcode I need to get the username out of quotes for my forum (PHP). The content I'm searching will be like this: [quote author=username link=topic=1234.msg1234567#1234567 date=1234567890] lorem ipsum dolor [/quote] lorem ipsum dolor sit amet All I need is the 'username'. The big prob...

Regex allow a string to only contain numbers 0 - 9 and limit length to 45

I am trying to create a regex to have a string only contain 0-9 as the characters and it must be at least 1 char in length and no more than 45. so example would be 00303039 would be a match, and 039330a29 would not. So far this is what I have but I am not sure that it is correct [0-9]{1,45} I have also tried ^[0-9]{45}*$ but that...

regex to validate a message-ID as per RFC2822

I have not found a regexp to do this. I need to validate the "Message-ID:" value from an email. It is similar to a email address validation regexp but much simpler, without most of the edge cases the email address allows, from rfc2822 msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] id-left = dot-atom-te...

PHP / Regex / preg_match_all

I'm using preg_match_all to get the quoted users from a post on a forum like so: preg_match_all('/quote author=(.*) link=/', $post, $quotedUsers); The $post string will typically be something like: [quote author=John link=topic=1234.msg123456#msg123456 date=1234567890]Lorem ipsum dolor sit amet[/quote] Lorem ipsum dolor sit amet ...

PHP RegEx Capture with Single Quotes

Hi all, I'm trying to capture from the following string: var MyCode = "jdgsrtjd"; var ProductId = 'PX49EZ482H'; var TempPath = 'Media/Pos/'; What I'd like to get is the variable length value between the single quoted ProductId value PX49EX482H I had this, and I think it is close, but the single quotes are tripping me up. I'm not s...

javascript - find range value between two floats

I have a string like so: (999.08) - (1025.67) I need to be able to find the range between these two values as a floting point even if they are negative values so (-999.08) - (-1025.67) would also be in scope. Assume i would need to use a regex and join the two in some sort of array? ...

asp.net mvc regular expression enter

^[a-zA-Z0-9-_. ]*$ for textarea I want to make available the enter as well in the following regular expression. How would I do that? ...

Why does this regex fail on a single use case - a text string containing an ampersand?

I'm trying to find a regex to separate out the author and book title information from a data set. This one seems to work fine: ^\s*(?:(.*)\s+-\s+)?'?([^']+'?.*)\s*$ On the data below, it identifies an author in group 1 as the text preceding the first hyphen and, in the case of no hyphen, it identifies a book title in group 2: Willia...

Look Around does not deliver expected result with .net

I want to use a look-ahead regex for replacement with the System.Text.RegularExpression.Replace(...) method. Now I am wondering what's wrong. Look at this example code: string input = "stackoverflow"; string replacement = "#"; var pattern1 = "(?=[a-z])o"; var result1 = Regex.Replace(input, pattern1, rep...

Python: how to substitute and know whether it matched

I know that re.sub(pattern, repl,text) can substitute when pattern matches, and then return the substitute my code is text = re.sub(pattern, repl, text1) I have to define another variable to to check whether it modified text2 = re.sub(pattern, repl, text1) matches = text2 != text1 text1 = text2 and, it has issues, e.g. text1='abc...

I need a REGEX to validate a password field

The password must have between 6-15 character and cannot allow the & and %. Thanks ...

What logic to use to rollup/merge multiple person entities as the same? (tight, but fuzzy enough to broaden matches)

I have multiple instances of people entities which are often times the same person. Where the address First-Last is the same at the same address, it's a no-brainer to merge/rollup them. However, due to data entry inconsistencies, there must be a way to deviate a bit from the exactness. I think the credit card industry does this a little...

Regular Expression in C#

Hi, i want to validate the input of a text box so as not be empty and also to accept only decimal or integer. I have tried the following regex's: ^\S[0-9],?[0-9]$ this one allows one letter at the beginning ^\S[0-9]+,?[0-9]*$ this one althought that does not allow letters, it requires for at least 2 numbers which is not desired. tha...