Guy_ Posted October 3, 2015 Posted October 3, 2015 (edited) I could use a lesson in laziness... I sometimes come across this problem where I think I need to use regex 'lazy' and the stuff I'm trying doesn't work, cos I need an eye-opener example for one of my typical problems...As an example a string of text where I *only* want the red spaces selected (or have a usable $1 and $2) after each piece of "quoted text" longer than 6 characters:"12345!" Txt "12345!" Txt "123456789!" Txt "12345!" Txt "12345!" Txt "12345678!" TxtThe problem with what I'm trying is that it seems greedy and the selection doesn't stop at the first quote character (going backwards)...I try '(?U)' and other stuff, but not seeing the light yet...This is *not* what I want. I want the "12345!" instances ignored... (BTW: don't use '\d', cos it could be anything inside the quotes)TIA Edited October 3, 2015 by Guy_
jguinch Posted October 3, 2015 Posted October 3, 2015 Can you try this ?(["ˮ][^ˮ"!]{6,}!["ˮ])(?=\s\w+) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Guy_ Posted October 3, 2015 Author Posted October 3, 2015 (edited) Can you try this ?Yes, I got that to work for my purposes It may have a tiny mistake (or not) with the quotes, that I seem to have corrected.I also got the impression that there are two types of typographers quotes that look exactly alike in some fonts and therefore I had to experiment a bit...So it seems it had nothing to do with 'laziness' and you used another technique (with help of the exclusions, is my guess.)I needed to understand that better too, so that will help me many times.BTW: My intention was to double up the spaces behind the longer quotes, so I can now replace with "$1 "Thanks!! Edited October 3, 2015 by Guy_
jvanegmond Posted October 4, 2015 Posted October 4, 2015 Don't use lazy, use not. For example to get stuff between quotes use:"[^"]+"This means: Match a quote followed by anything that is not a quote a number of times followed by a quote. github.com/jvanegmond
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now