Find all characters between " " quotes

Find, replace, find in files, replace in files, regular expressions

Find all characters between " " quotes

Postby dman357 » Fri Mar 14, 2008 10:25 am

I have a large ascii file with characters delimited with quotes( " " ). However there are CRs between the beginning quote and the ending quote. I have tried using the UE find "[~)]+" but it didn't work. I'm brand new to UE so any suggestions would help.
dman357
Newbie
 
Posts: 1
Joined: Fri Mar 14, 2008 10:11 am

Re: Find all characters between " " quotes

Postby pietzcker » Fri Mar 14, 2008 1:09 pm

Please read the forum readme topic. Mofi has compiled a wealth of information about find/replace operations there.

Assuming (since you say you're brand new to UE) that you have UE V14, do the following: Click on the Advanced button in the search dialog and choose "Perl" as your regex engine. Then check the "Regular expressions" checkbox.

Search for
Code: Select all
"[^ÿ]*?"


Explanation: Match a ", then match any character(s) that are not a ÿ (assuming that this character will never turn up in your files), then match another ". The * means "match zero or more times", the ? makes the * a "lazy quantifier" meaning "match as few characters as possible that still allow the overall regex to match. If you dropped the ? it would match from the very first " all the way to the very last " in your entire file.

HTH,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Find all characters between " " quotes

Postby Jane » Thu Mar 20, 2008 11:22 am

Tim,
I'm puzzled about your use of ÿ in the negated character class. Why couldn't you just use a negated quote:
i.e. "[^"]*?"
Using your lazy quantifier it would single step from the first quote until it hit the second one. Maybe I'm missing something here?

Cordially,
jane
User avatar
Jane
Basic User
Basic User
 
Posts: 22
Joined: Sat Aug 05, 2006 11:00 pm
Location: Canada

Re: Find all characters between " " quotes

Postby pietzcker » Thu Mar 20, 2008 11:51 am

You're absolutely right, of course! <duh!>

I'm so used to this ÿ-trick to overcome the lack of a "dot matches newline" option that I overlooked the best solution. You don't even need the ? anymore. "[^"]*" should be enough.

Cheers,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm


Return to Find/Replace/Regular Expressions