regex

Regular Expression to get contents of div class in php

Hi, Is there any special syntax to get nested div element with unique class name in RegExp in php. Consider I have a syntax like <div style="demo"> <div class="row"> <div title="[email protected]" class="text">ABC</div> </div> <div class="row"> <div title="[email protected]" class="text">PQR</div> </div></div> here how can we r...

Regular Expression to match relative URLs

Looking for a regular expression that match the following relative URLs: All urls starts with /abc/ but we don't know where it ends and it doesn't have any file extension at the end. /abc/xyz /abc/part1/part2 /abc/red/blue/white/green/black and so on. Any help? ...

need help to create regular expression

i need regular expression which is not allow ...

Regular Expression to get contents of anchor tag InnerHTML in php

Hi, I need to retrieve anchor tag innerHTML using RegExp in php. Consider I have a syntax like <div class="detailsGray"><span class="detailEmail"><a href="http://example.com"class="fontLink"&gt;[email protected]&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; Try to get it by preg_match_all('/class=\"fontLink"\>.*\<\/a\>/', $raw, $matches); ...

Using .NET RegEx to retrieve part of a string after the second '-'.

Hey guys, This is my first stack message. Hope you can help. I have several strings i need to break up for use later. Here are a couple of examples of what i mean.... fred-064528-NEEDED frederic-84728957-NEEDED sam-028-NEEDED As you can see above the string lengths vary greatly so regex i believe is the only way to achieve what ...

Validate datestring "dd.MM.yyyy" to see if input is numeric

I have a textbox containing a date in the format "dd.MM.yyyy". Now I want to use a RegularExpressionValidator to see if the format matches "digit digit . digit digit . digit digit digit digit" (without spaces) How does the regular expression look like for this? ...

in matcher.replace method,how to limit replace times?

in matcher.replace method,only has: replaceFirst() and replaceAll() two methods i want limit replace 3 times,how to do? example: String content="aaaaaaaaaa"; i want to get result is: "bbbaaaaaaa" my code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class T1 { public static void main(String[] args) { ...

How can I separate string array via REGEX?

I separated "A320-789-890" according to "-" and i get a list below: "A101C", "B7CL", "E7CL", "D7CL" Everything is ok. My result set above it is my solution result. But i have 2 question: how can I do that with regex? if I can do that with regex, can I use regex with linq? which is more effective according to performance like my meth...

regex int + comma

Hi, i need a regex for: 123,456,789,123,4444,... basically comma separated values. The INT part can be 1-4 numbers long, followed by a comma...always in this form... /^([0-9]{1,4})(\,)?$/ This obviously doesn't work... Thanks! ...

Regular expression with repetition?

Hi all I need a regular expression that accepts only digits and dots, with these conditions: between digits three must be only one dot '132.632.55' digits can be repeat in between two dots '.112234563456789.' the string starts with digits digits with "." like this '123346547987.' can repeat many times length of these digit...

Anyone got a regex for all known international postcode/zipcodes?

I've been searching for a global postcode based regex but not found one. Anyone know of one that exists? ...

How can you get subdomain.site.com and www.site.com down to the domain name

In javascript is it possible to create a function that checks an url to find the domain name. EG: if these sites: www.site.co.uk www.subdomain.site.co.uk site.co.uk subdomain.site.co.uk were put into the function they would be returned as "site.co.uk". ...

regex double white space separation problem

Hello, I want a regex to match words that are delimited by double or more space characters, e.g. ABC DE FGHIJ KLM NO P QRST Notice double or more spaces between the alphabets. Writing regex for such a problem is easy as I only need the first 4 words, as we may search for a word by using \S+ or \S+? However, for my problem, o...

What does the following ^.*$ regexp match?

Can someone explain what the following regexp matches? ^.*$ Thank you! ...

rewriting URLs with regular expressions

I wish to transform a querystring using a regular expression replace in C#. I have a number of defined querystring parameters (i.e. A, B and C). I wish to transform something like this page.aspx?A=XXX&B=YYY&C=1 into: page/XXX/YYYY/true Note that the first two parameters values for A and B are simply concatenated, but the part I'm...

reg ex telephone number

How do i change any of the following to just numbers 1-(999)-999-9999 1-999-999-9999 1-999-9999999 1(999)-999-9999 1(999)999-9999 i want the final product to be 19999999999 ...

preg_replace exact opposite [php 5.2.10]

I'm looking to do something like get the opposite match from this line: $input = "21.asdf*234true;asdf0--11" $_BOOL_ ="/(true|false)/i"; $output = preg_replace($_BOOL_, '', $input); //Result: "21.asdf*234;asdf0--11" //Desired result: "true" Which ofcourse in php 5.3 is $output = preg_filter($_BOOL_, '', $input); But I'm on 5.2, and...

difference between \r and \n

what is the difference between \r and \n in regular expression. can some one explain me with an example ? ...

Strange result on perl regexp - end string anchor & ungreedy at once.

I have a very simple substitution: my $s = "<a>test</a> <a>test</a>"; $s =~ s{ <a> .+? </a> $ }{WHAT}x; print "$s\n"; that prints: WHAT But I was expecting: <a>test</a> WHAT What do I misunderstand about "end string anchor" in interaction with ungreedy option? So, I was wrong about regexp engine. Indeed, dont humanize code -...

How to wrap long lines in a text using Regular Expressions when you also need to indent the wrapped lines?

How can one change the following text The quick brown fox jumps over the lazy dog. to The quick brown fox + jumps over the + lazy dog. using regex? UPDATE1 A solution for Ruby is still missing... A simple one I came to so far is def textwrap text, width, indent="\n" return text.split("\n").collect do |line| line.sc...