regex

Date validation dd-mm-yyyy or dd/mm/yyyy

I get dates from a text area in the dd-mm-yyyy or dd/mm/yyyy format (the user is allowed to use - or /) How do I check (using a regex or php) if the date is valid? Is there a regex or php method done this far to validate dates in this format? I tried searching here but could not find anything. ...

Detect words or any character after some match pattern, Regex Pattern (Vim)

Hi...! I have a text file patterned like this : 1 textA == this is textA == 1.1 textB === this is textB === 2 textC == this is textC == 2.1 textD === this is textD === 2.1.1 textE ==== this is textE ==== Whats the right regex pattern to formatting the text above: == this is textA == === this is textB === == this is textC == === this ...

How would you process 1GB of text data?

Task: Process 3 text files of close to 1GB size and turn them into csv files. The source files have a custom structure, so regular expressions would be useful. Problem: There is no problem. I use php for it and it's fine. I don't actually need to process the files faster. I'm just curious how you would approach the problem in general. I...

Password strong - not require each condition

Hi It's my first post, so hello everybody. I have problem with regex expression. I have password validation by regex.This is my expression: ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$ It works - the password must contain at least 1 digit, at least 1 lower case letter, at least 1 upper case letter and at least special characte...

Regex - lookahead assertion

Hi I have problem with lookahead assertion (?=). For example, I have expression: /Win(?=2000)/ It match Win, if expression is like Win2000, Win2000fgF. I have next expression: ^(?=.*\d)(?=.*[a-z]).*$ It match for digit and lower case letter, for example: 45dF, 4Dd. But I don't know, why it works and match all characters :) I haven...

java 6 regex match question

Hi all, Couple of questions: 1) How to make the following regex which are based on search literal ^ work for the search literal | search literal ^ based regex (which works fine, which is one of the valuable inputs from this forum): String intermediateResult = in.replaceAll( "(TEST\\^[^^]*\\^\\^[^^]*\\^[^^]*\\^)\"\"\\^", "$1^" ); Stri...

build url from regex string containing named subpattern

Here is the match_url function I am using at the moment function match_url($urls,$url) { foreach($urls as $regex=>$args) { $r = str_replace('/','\/',$regex); preg_match("/$r/i",$url,$matches); if(count($matches) > 0) { $dispatch = array(); $args['args'] = array(); if(empty(...

How to create a macro for string containig ,<Status, tinyint,>

I just read little bit about macro and was trying to create the one in .net I was able to do very small operations since I dont know much about vb.net and regular expressions. I want to create a properties and variable declaration for the below code. What will be the regular expression to parse this string. So that I can get all the com...

sql ce escape '(single quote) C#

I am writing some code to store names in a database. I limit the names to only certain characters, but last names are a challenge. Since some people have single quotes in their name (example O'Brian) I need to allow this. So I wrote a regex replace to replace the ' with a \' which I assumed should make the ' a literal. It works as far...

How to replace a HTML-tags inner text content using C#!

Hello! Right now I'm working on a Internet Explorer add on which is supposed to scan a HTML-document for URL's in plain text, and then "linkify" them. I have access to the websites DOM, and had an idea to traverse all of the DOM nodes and search for "links" using RegEx, to replace these text with HTML-code, however, when changing the "...

Finding pairs in strings.

Hello, I was wondering if i can get some help with this problem. Suppose I had a string 34342 I would like to find the number of pairs in this string, which would be two. How would i go about doing that? EDIT: Ok what i really wanted was to match the occurrences of characters that are the same in the string. ...

Can I apply word-casing to a string using regular expressions?

Is it possible to convert an all-uppercase string into a string where only the first letter of each word is in upper case using regular expressions? THIS IS A SAMPLE STRING ---> This Is A Sample String At first I thought this would be an easy task, but now I don't even know how to start or even if it is possible. ...

Regex to find unqoted commas?

I'm thinking we can look for an even number of quotes to the left, and to the right of the comma... but I'm not quite sure how to write it. Anyone know? Actually..you'd just have to check either (left or right). I want to split on this, so it has to match only the comma. Example: one, "two, three" Should be split into two strings: ...

How do I create a regular expression to capture {this} text and exclude \{that}?

Hi Guys, I need a regular expression to capture field names listed in a string. They are listed between Here are my requirements: field names in curly braces field names have no spaces curly braces can be escaped with a \ So in the following: capture {this} text and exclude \{that}? The matches are {this} but not {that}. I'm us...

Help with regex: Anything inside a tag

Hello, I need to find anything inside a tr... <tr class="class1"> more tags here, multiple lines... </tr> How can I get anything that's between <tr class="class1"> and </tr>? thanks! ...

Two or more matches in expression

Is it possible to make two matches of text - /123/123/123?edit I need to match 123, 123 ,123 and edit For the first(123,123,123): pattern is - ([^\/]+) For the second(edit): pattern is - ([^\?=]*$) Is it possible to match in one preg_match_all function, or I need to do it twice - one time for one pattern, second one for second? Thank...

Help with regular expression

I am converting some associative array database calls to object orientated results. So I would love a reg exp I can use in find and replace to convert : $rsName['fieldName'] to $rsName->fieldName ...

How to change all non word characters and multiple spaces into ' ' and then all space to '-' in one preg_replace()

Hello All, I want to change image names on below conditions All non word characters turns into space and then all spaces turns into - means if my image name is : Hello My name is'Kh@n "Mr. .Khan " then it should be changed into Hello-My-name-is-kh-n-mr-Khan . i need to use below in two steps, $old_name =' ...

python regex speed

Hi guys, regarding regex (specifically python re), if we ignore the way the expression is written, is the length of the text the only factor for the time required to process the document? Or are there other factors (like how the text is structured) that play important roles too? ...

PHP Preg_match: attempt to match a string where a substring does not exist in the string

Hi, I have been trying to get this regex work. Suppose to parse an URL, if the string '_skipThis' is found, don't match the string. Also backreferences are needed too. For example: String 1: a_particular_part_of_string/a/b/c/d/e/f Result: preg_match should return true Backreference: $1 -> a_particular_part_of_string, $2 -> /a/b/c/d/e/f ...