problems with double newlines

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

problems with double newlines

Postby holden » Tue Jul 03, 2012 4:27 pm

I'm trying to get this:
sometext

sometext,sometext,sometext
sometext,sometext,sometext
sometext,sometext,sometext

sometext,sometext,sometext
sometext,sometext,sometext
sometext,sometext,sometext

sometext,sometext,sometext
sometext,sometext,OTHERTEXT

sometext,sometext,sometext

sometext,sometext,sometext
sometext,sometext,sometext
sometext,sometext,sometext


but getting only this:
sometext

sometext,sometext,sometext
sometext,sometext,sometext
sometext,sometext,sometext

sometext,sometext,sometext
sometext,sometext,sometext
sometext,sometext,sometext

sometext,sometext,sometext
sometext,sometext,OTHERTEXT

sometext,sometext,sometext

sometext,sometext,sometext
sometext,sometext,sometext
sometext,sometext,sometext


/(\r\r)[^\1]*othertext/gis

please help
holden
Forum Newbie
 
Posts: 1
Joined: Tue Jul 03, 2012 4:17 pm

Re: problems with double newlines

Postby tr0gd0rr » Mon Jul 09, 2012 2:59 pm

It may be easier to split the text on \r\r first and then run a regex on each chunk.
User avatar
tr0gd0rr
Forum Contributor
 
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: problems with double newlines

Postby ragax » Sun Jul 29, 2012 4:22 pm

This works in RegexBuddy, PCRE flavor:

Syntax: [ Download ] [ Hide ]
(?s)\r\n\r\n[^\r]+\r\n[^\r]+OTHERTEXT


I used \r\n because I'm on Windows, if you're on unix you can remove the three instances of \n.

The (?s) means "dot matches new line", works in PCRE, if you are using a different flavor, use the appropriate flag.
User avatar
ragax
Forum Commoner
 
Posts: 85
Joined: Thu Dec 15, 2011 2:40 pm
Location: Nelson, NZ


Return to Regex

Who is online

Users browsing this forum: Google [Bot] and 2 guests