24129RE: [Clip] REGEX Search Backward
- Nov 3, 2013
Additionally, many URL's are enclosed in angle brackets. In order to start the capture at the beginning of the url in every case, and assuming you don't want to capture the angle brackets if present, then another negative class should be added to the .+ term so that none of these things can be caught up in the greediness.
^!Find "(?s).+[^\r\n</\"][</"]*\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW
So, now the .+ can't end with <, " or /. If < or " are present, they are passed but not captured. Now, if the http is first, it will be captured, but if the www is first, it will be captured.
> The regex finds and highlights only www.logicalchess.com/ instead ofYes, John already mentioned that problem himself. If the start can be
> the full http://www.logicalchess.com/.
either http or www and the term before is greedy, then you'll capture as
little as possible. To solve this you have to look at what always comes
directly before your string. It may be an equals (=) or a quote, if the
URL is always placed in quotes. Assuming the latter I get:
^!Find "(?s).+"\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW
As you never specified what comes outside your search string, I had to
- << Previous post in topic Next post in topic >>