regex

US Phone Number Verification

I have a website form that requires a US phone number input for follow up purposes, and this is very necessary in this case. I want try to eliminate users entering junk data 330-000-0000. I have seen some options of third parties that validate phone numbers for you, however idk if that is the best option for this situation. However if yo...

Flex : Filter a datagrid using a combobox value that is contained in a datafield

I have a filter in a combobox with a number of entries. Instead of filtering the datagrid with an exact match, I would like to take the selected value and only display records where the selected value is contained in the datafield. For example: the user selects a value of "New" and the datagrid displays records where the contents of the ...

Algorithm to get a Regex

Something like this is in my mind: I put one or a few strings in and the algorithm shows me a matching regex. Is there any "easy" way to do this, or something like this already exists? Edit: Yes, I'm trying to find a way to generate regex. Edit: Regulazy is not the thing i'm searching for. The common use for the code i want is to fin...

How can I find repeated letters with a Perl regex?

I am looking for a regex that will find repeating letters. So any letter twice or more, for example: booooooot or abbott I won't know the letter I am looking for ahead of time. This is a question I was asked in interviews and then asked in interviews. Not so many people get it correct. ...

flex (lexical analyzer) regular expressions - Reusing definitions

Hi, I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions DIGIT [0-9] VALID [a-zA-Z] How can I rewrite the IDENTIFIER rule to use the DIGIT and VALID definitions? I don't know how to do the "second" match, I'm stuck here: IDENTI...

Explain this mod_rewrite rule

Can anyone explain what this mod_rewrite rule is doing? I'm trying to comment the file, but the code seems to state the opposite of what I think it's doing # Enable rewriting of URLs RewriteEngine on # Allow specified file types to be accessed # Thing to test = URL # Condition = not starting with RewriteCond $1 !^(index\.php|images...

What regex will match text excluding what lies within HTML tags?

I am writing code for a search results page that needs to highlight search terms. The terms happen to occur within table cells (the app is iterating through GridView Row Cells), and these table cells may have HTML. Currently, my code looks like this (relevant hunks shown below): const string highlightPattern = @"<span class=""Highlight...

Replace patterns that are inside delimiters using a regular expression call

I need to clip out all the occurances of the pattern '--' that are inside single quotes in long string (leaving intact the ones that are outside single quotes). Is there a regular expression way of doing this? (using it with an iterator from the language is OK). For example, starting with "xxxx rt / $ 'dfdf--fggh-dfgdfg' ghgh- dddd -...

What is the difference between Python's re.search and re.match?

What is the difference between the search() and match() functions in the Python re module? I've read the documentation, but I never seem to remember it. I keep having to look it up and re-learn it. I'm hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head. Or at least I'll have a better p...

regular expression to extract text from HTML

I would like to extract from a general HTML page, all the text (displayed or not). I would like to remove any HTML tags Any javascript Any CSS styles Is there a regular expression (one or more) that will achieve that? ...

Search then Extract

I have here a multiple data, I want to search a name and date, if I typed JULIUS CESAR as name then the whole data about JULIUS will be extracted.? What if i want only to extract information? This file was save in texteditor(linux). # Record number: 1 Date: 08-Oct-08 Time: 23:45:01 Name: JULIUS CESAR Address: BAGUIO CITY, Philippines I...

Regex Partial String CSV Matching

Let me preface this by saying I'm a complete amateur when it comes to RegEx and only started a few days ago. I'm trying to solve a problem formatting a file and have hit a hitch with a particular type of data. The input file is structured like this: Two words,Word,Word,Word,"Number, number" What I need to do is format it like this......

Regex to match alphanumeric and spaces

What am I doing wrong here? string q = "john s!"; string clean = Regex.Replace(q, @"([^a-zA-Z0-9]|^\s)", string.Empty); // clean == "johns". I want "john s"; ...

C++: what regex library should I use?

I'm working on a commercial (not open source) C++ project that runs on a linux-based system. I need to do some regex within the C++ code. (I know: I now have 2 problems.) QUESTION: What libraries do people who regularly do regex from C/C++ recommend I look into? A quick search has brought the following to my attention: 1) Boost.R...

Regexp: Substituting a version number in an XML file

Ok I give up, I've been trying to write a regexp in ant to replace the version number from something that I have in a properties file. I have the following: <?xml version="1.0" encoding="UTF-8"?> <feature id="some.feature.id" label="Some test feature" version="1.0.0" provider-name="Provider">...

How can I match a pipe character followed by whitespace and another pipe?

Hello. I don't usually post to forums, but I am somewhat stuck. I am trying to find all matches in a string that begins with "| |" (quotations not included). I have tried doing: if ($line =~ m/^\\\|\s\\\|/) and that didn't work. I'm not sure if anyone has any tips or pointers, but any help would be appreciated. Thanks! ...

MYSQL: REGEXP single quotation matching

I am having a trouble matching a string in a MySQL-query with the following regex: I want it to match to this string: "Rue de l' Harmonie" SELECT id, street_name FROM street_names WHERE street_name REGEXP '^(rue[a-z]+[[:blank:]])((du|de|la|des|d[\']|l[\'])[[:blank:]])*[[:<:]]HARMONIE$' Anybody can give me a hint? ...

JavaScript style/optimization: String.indexOf() v. Regex.test()

I've recently come across this piece of JavaScript code: if (",>=,<=,<>,".indexOf("," + sCompOp + ",") != -1) I was intrigued, because to write this test I would have done: if (/(>=|<=|<>)/.test(sCompOp)) Is this just a stylistic difference, or does the author of the other code know something about optimization that I don't? Or per...

.NET Regex balancing groups expression - matching when not balanced

.NET balanced group regexes make my head explode. I've got this string i'm trying to match: other stuff blah blah.... { stuff stuff {key: stuff stuff } } more stuff........

Regex failing on right parens

I have this .NET regex: ^(?<prefix>("[^"]*"))\s(?<attrgroup>(\([^\)]*\)))\s(?<suffix>("[^"]*"))$ It properly matches the following strings: "some prefix" ("attribute 1" "value 1") "some suffix" "some prefix" ("attribute 1" "value 1" "attribute 2" "value 2") "some suffix" It fails on... "some prefix" ("attribute 1" "value (fail) 1"...