RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
\b(\w+)\s+\1\b
Description
Uses backreferences and word boundaries to match repeated words seperated by whitespace without matching a word with the same ending as the next words beginning.
Matches
Tell the the preacher | some some | hubba hubba
Non-Matches
once an annual report | mandate dated submissions | Hubba hubba
Author Rating: Not yet rated. Sean Carley
Source Update of expression submitted by Steven Smith (recalled from "Mastering Regular Expressions" from O'Reilly)
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: expression
Name: kiran
Date: 12/15/2004 11:58:53 PM
Comment:
what is the regular expression pattern for Date(DD/MM/YYYY), IP address, MAC ID, TIME, E-MAIL ID, and a website url.


Title: How about multiple repeats?
Name: Andy
Date: 12/11/2004 5:59:52 AM
Comment:
Works great, but how do I replace multiple repeats with a single; e.g. in 'This is a a a test'?


Title: TextPad equivalent
Name: Erich Spencer
Date: 12/10/2003 1:57:47 PM
Comment:
(\<[[:word:]]+)[[:space:]]+\1\> TextPad regex supports POSIX character classes but not Perl Compatible Regular Expression (PCRE) character types. So "\b", "\w", and "\s" must be replaced with their class counterparts. Also, TextPad recognizes a beginning word boundary "\<" and an ending word boundary "\>". NOTE: Make sure to enable "Use POSIX regular expression syntax" in Configure -> Preferences -> Editor to minimize reliance on additional escape characters in your regex.


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials