Find Quoted text over a line break

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

Moderator: General Moderators

Post Reply
rwilkin
Forum Newbie
Posts: 3
Joined: Sat Jan 29, 2011 12:10 am

Find Quoted text over a line break

Post by rwilkin »

Hi,
I'm a real noob when it comes to regex's. I've been researching this for 3 days now and have hit a wall.
I have a regex to find all of the following line:
named "name 1"
named "name 2"
etc etc.

however in the file I get sometimes the names will appear like so:
named "name 1"
named "name 2"
named
"name 3"
named
[tab] "name 4"

the regex I have created is

Code: Select all

'/named([\s]|[\r\n])"([^"]+)"/i'
which will find name 1 and name 2 but never 3 or 4.
Can anyone help me/tell me what I'm doing wrong?
~ Rob
User avatar
ridgerunner
Forum Contributor
Posts: 214
Joined: Sun Jul 05, 2009 10:39 pm
Location: SLC, UT

Re: Find Quoted text over a line break

Post by ridgerunner »

Try this:
[text]'/named(\s+)"([^"]+)"/i'[/text]

Note that \r and \n are included in \s, so this can be greatly simplified:
[\s]|[\r\n] == [\s\r\n] == [\s] == \s
rwilkin
Forum Newbie
Posts: 3
Joined: Sat Jan 29, 2011 12:10 am

Re: Find Quoted text over a line break

Post by rwilkin »

Thank you very much ridgerunner.
I ended up using

Code: Select all

'/named\s*?"([^"]+)"/i'
not sure which would be better?? they both work :D
Post Reply