regex

How to validate ID number in asp.net?

Hi, I am new at this so be easy on me... :) I need to validate if a the ID number that the user typed in my site is a valid ID. How do I check it? Do I need to use RegularExpressionValidator? More over, I also need to validate the credit card number, I found a few RegularExpressions for that in the net but each one is different ...

How to remove unclosed <P> tags from xhtml

Possible Duplicate: Removing unclosed opening <p>tags from xhtml document I have a big xhtml Document consisting of lots of tags. I have observed that a few unclosed opening paragraph tags are repeating unnecessarily and I want to remove or replace them with blank space. I just want the code to identify unclosed paragraph ta...

How do I include - and ' in this regular expressions?

I have a this regular expression below for some input name fields. How do I include an apostrophe and a hyphen in this? InputField("tFName", /^[a-zA-Z-\-\ ]+$/); ...

TCL regsub isn't working when the expression has [0]

I tried the following code: set exp {elem[0]} set temp {elem[0]} regsub $temp $exp "1" exp if {$exp} { puts "######### 111111111111111 ################" } else { puts "########### 0000000000000000 ############" } of course, this is the easiest regsub possible (the words match completely), and still it doesnt work, and no sub...

RegularExpression for URL Rewriting

I am using urlrewriter.net and I am trying to make a redirection. So here is the condition, If the requested url doesn't end with a / (slash) and then add / at the end of the url and redirect to added url. So if the url is "http://www.something.com/cases" then add / and redirect it to "http://www.something.com/cases/" I've use...

Check if two parts of a string are the same with regex (PHP)?

Hi guys, using a regular expression in PHP with preg_replace_callback how can I check if two parts of the pattern are the same? preg_replace_callback('/Blah: (.*?), BLah Blah (.+?), (**String Here Must Be Same as First Match**)/s', create_function(), $subject); Thanks, Matt ...

I have an issue with secret question input regular expressions In Javascript

Any suggestions on how to include double quotes ("") in this expression? InputField("tSecAnswer1", /^(?=.*[a-zA-Z\d])(\w|[\s\.\@\-\?\,\&\/\_\#\+\(\)\"'"]){3,50}$/); ...

Simple PHP regular expression question

What's the most efficient preg_match regular expression for the following: The regular expression must match a certain string (case insensitive) Can be followed by [ or ; and then something else These are the test cases for "foo": foo --> good food --> bad foo; --> bad, need something after ; FOO;bar ...

removing dots and slashes regex - non relative

how could I remove the trailing slashes and dots from a non root-relative path. For instance, ../../../somefile/here/ (independently on how deep it is) so I just get /somefile/here/ ...

How to create a function in Excel to validate cells using RegExs

I have a long spreadsheet with tariff codes that I need to validate and I would like to create a function with RegEx to do it automatically (this is a daily task that I will have to do for the following months and I would like to automatize) For example in Column A, I have the following data: CODE 1000.00.00 1000.10.00 1020.12.99 ... ...

javascript regexp can't find way to access grouped results

Hello, re = /\/?(\w+)\/(\w+)/ s = '/projects/new' s.match(re) I have this regular expression which I will use to sieve out the branch name, e.g., projects, and the 'tip' name, e.g., new I read that one can have access to the grouped results with $1, $2, and so on, but I can't seem to get it to work, at least in Firebug console When ...

A probably simple regex expression

I am a complete newb when it comes to regex, and would like help to make an expression to match in the following: {ValidFunctionName}({parameter}:"{value}") {ValidFunctionName}({parameter}:"{value}", {parameter}:"{value}") {ValidFunctionName}() Where {x} is what I want to match, {parameter} can be anything $%...

Javascript REGEX : Tags

I want to convert words into tags. So for example I have an input, if I type in in this apple, windows, stackoverflow, google, microsoft then I will get this: apple windows stackoverflow google microsoft Delimiters should be space, semicolon, or comma, just like in stackoverflow :) ...

php regex city state zip

this is from an array i have [citystatezip] => New York, NY 50805-2578 i'm trying to have it in the format below [city] => New York [state] => NY [zip] => 50805-2578 i was using regex in php..but got nowhere. thanks for the help. ...

How to read data in certain format

I have a log file that can get pretty big. The information in my log file is in a certain format and I want to be retreiving them a seperate blocks of data. For example, This is the start. Blah Blah Blah Blah Blah Blah Blah Blah Blah This is the start. Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Bla...

Regex to parse out filename and partial path, conditionally

I have a C# app that uses the search functions to find all files in a directory, then shows them in a list. I need to be able to filter the files based on extension (possible using the search function) and directory (eg, block any in the "test" or "debug" directories from showing up). My current code is something like: Regex filter = n...

replace an item in a html tag spanning multiple lines

I have a text file with html: Blah, blah, blah some text is here. <div> something here something else </body></html> so far, if the tags are on one line this works: textfile = open("htmlfile.txt", "r+") text = textfile.read() a = re.search('<div.+?<\/html>', text) repstr = c.group(0) text = text.replace(repstr, '', 1) works ...

Regex Parsing HTML

Possible Duplicate: RegEx match open tags except XHTML self-contained tags I would like to ensure that HTML attributes have quotes around them as is required by xhtml. For example: <BODY link=#0000ff vLink=#800080> should be <BODY link="#0000ff" vLink="#800080"> I am looking for a Regex pattern that would handle this. ...

How does this Java regex detect palindromes?

This is the third part in a series of educational regex articles. It follows How does this regex find triangular numbers? (where nested references is first introduced) and How can we match a^n b^n with Java regex? (where the lookahead "counting" mechanism is further elaborated upon). This part introduces a specific form of nested as...

Do all languages support any common regex syntax ?

Is there any regex standard ? Is PCRE supported by all regex engines ? Thanks for replies ...