regex

Visual Studio Search Issue.

I have a problem in VS2005. When I try to search files with the regular expressions option I just get an error message stating Unknown argument for ':' operator. Complete Regular Expression required in search string. The pattern that i'm trying to use is valid, and works in other text editors it is: <asp:textbox.+?(type="text"|size...

Parameterised regular expression in Python

In Python, is there a better way to parameterise strings into regular expressions than doing it manually like this: test = 'flobalob' names = ['a', 'b', 'c'] for name in names: regexp = "%s" % (name) print regexp, re.search(regexp, test) This noddy example tries to match each name in turn. I know there's better ways of doing t...

using string iterators over char* in boost regex

I am trying to search a char* to find matches and store each match as a struct using boost regex. I do not know how to use the std::string iterators over char*. So I created std::string from char* and using them. But now I want pointers in the original char* which can only be found using std::string I created. See the following code. The...

Match series of (non-nested) balanced parentheses at end of string

How can I match one or more parenthetical expressions appearing at the end of string? Input: 'hello (i) (m:foo)' Desired output: ['i', 'm:foo'] Intended for a python script. Paren marks cannot appear inside of each other (no nesting), and the parenthetical expressions may be separated by whitespace. It's harder than it might seem...

Validating an IP with regex

I need to validate an IP range that is in format 000000000 to 255255255 without any delimiters between the 3 groups of numbers. Each of the three groups that the final IP consists of should be 000 (yes, 0 padded) to 255. As this is my 1st stackoverflow entry, please be lenient if I did not follow etiquette correctly. ...

using RegExp to split string but store whitespace (space or crlf) to items

sample input (orgtext = a[crlf]b[space]c[crlf] ) I like to store each word a,b, c to the words array with the original suffix crlf or space. Currently calling SPLIT drops the suffix as its separator, but I like to store separator as well. Can I adjust regexp to return also suffix and still split? Words = new Array; var ar: Array = ...

How to check real names and surnames - PHP

Hi everybody, here's my problem: I want to check if a user insert a real name and surname by checking if they have only letters (of any alphabet) and ' or - in PHP. I've found a solution here (but I don't remember the link) on how to check if a string has only letters: preg_match('/^[\p{L} ]+$/u',$name) but I'd like to admit ' and - t...

Regex to find data in specific column of a line

I'm trying to search a document for data on a specific column. I am trying to use: ^.{x}[data to find] where x is the number of columns I want - 1. I'm not sure if I am doing something wrong, or if my regex engine does not support that syntax. I am trying to use Notepad++, if that is helpful. ...

Limit the number of words in a response with a regular expression

Does anybody have a regular expression that would work to limit the number of words in a response? For instance, I'd like to use it with jQuery validate so I can restrict a textbox/textarea to have say 250 words. The boxes will be plain-text. I've done some Googling but none of the ones I've found were very good. They mostly centered ar...

String separation in required format, Pythonic way? (with or w/o Regex)

I have a string in the format: t='@abc @def Hello this part is text' I want to get this: l=["abc", "def"] s='Hello this part is text' I did this: a=t[t.find(' ',t.rfind('@')):].strip() s=t[:t.find(' ',t.rfind('@'))].strip() b=a.split('@') l=[i.strip() for i in b][1:] It works for the most part, but it fails when the text part h...

linking to boost regex in gcc

i am trying to compile my program which uses regex on linux. I built the boost library in the libs/regex/build by typing make -fgcc.mak which created a directory gcc which contains the following four files boost_regex-gcc-1_35 boost_regex-gcc-d-1_35 libboost_regex-gcc-1_35.a libboost_regex-gcc-d-1_35.a Now I want to use regex ...

How to use regular expressions to match everything before a certain type of word

Hi, I am new to regular expressions. Is it possible to match everything before a word that meets a certain criteria: E.g. THIS IS A TEST - - +++ This is a test I would like it to encounter a word that begins with an uppercase and the next character is lower case. This constitutes a proper word. I would then like to delete everything...

Matching a space in regex

I need to match a space character in php regex. Anyone got any ideas? EDIT I mean like "gavin schulz" the space in between the two words. I'll make another clarification. I did try and find more info but nothing turned up. Anyways I am using a regex to make sure that I only allow letters, number and a space. But I'm not sure how t...

Returning a portion of a regular expression match

This question shows my ignorance of regular expressions. I've never understood it quite enough. If I wanted to match, for instance, just the URL portion of an tag in HTML, what would I need to do? My regular expression to get the entire tag is: <A[^>]*?HREF\s*=\s*[""']?([^'"" >]+?)[ '""]?> I have no idea what I would need to do to...

Regular vs Context Free Grammars

I'm studying for my Computing languages test and there's one idea I'm having problems wrapping my head around. I understand that Regular Grammars are simpler and cannot contain ambiguity but can't do a lot of tasks that are required for programming languages. I also understand that Context Free Grammars allow ambiguity, but allow for s...

Regular expressions Equivalence

Is there a way to find out if two arbitrary regular expressions are equivalent? Looks like complex problem to me, but there might be some DFA simplification mechanism or something? ...

Is there a performance difference in these two social security number searches?

I need to do a search for people who are violating our "don't use social security numbers in your data" rule and need to know if there are performance differences (and why) between the two lines below. Thanks. [0-9]{3}-[0-9]{2}-[0-9]{4} vs \d\d\d-\d\d-\d\d\d\d Requested Details: engine: removed to stop confusion in tagging ...

Regexs works in firefox, but not in i.e. 7.0

Seems there are some problems using asp.net regular expression validators where they work in firefox but not in some flavors of i.e. (and maybe vice-versa, I don't know). Anyway, anyone have a replacement for this: ([a-zA-Z1-9]*)\.(((P|p)(D|d)(F|f))|((d|D)(o|O)(c|C))) To basically match any filename/path with a PDF or Doc extension? ...

Regex for checking if a string has mismatched parentheses?

In a PHP script, what regex should I use to check for mismatched parentheses in a string? Things that I want to allow include: This is (ok) This (is) (ok) Things I want to prevent: This is )bad( This is also (bad This is (bad (too) Thanks! Update: You guys all rock. Doing this with a regex seemed trickier than it should have,...

Regex splitting strings on a character, not contained in ()

I'm trying to split a string on a , where that character is not contained in (). Example String: `table1`.`lname`,`table1`.`fname`,if(foo is not null,foo,if(bar is not null,bar,table3.baz)),`table3`.`shu` I want to split it into an array looking like ( 0=>`table1`.`lname` 1=>`table1`.`fname` 2=>if(foo is not null,foo,if(bar is...