Mobile app version of vmapp.org
Login or Join
Kaufman565

: GREP rule to catch all types of web link / URL I'm looking to build a robust, reliable GREP rule to catch all web links and URLs that appears in text, covering all possible characters and

@Kaufman565

Posted in: #AdobeIndesign #Grep

I'm looking to build a robust, reliable GREP rule to catch all web links and URLs that appears in text, covering all possible characters and gotchas like HTTPS, or URLs in brackets like (http://whatever.com), or followed by punctuation like whatever.com?! It's for an InDesign paragraph style GREP rule.

I've put the best I've come up with so far down below as an answer - is it missing anything, is there anything more robust or straightforward?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kaufman565

1 Comments

Sorted by latest first Latest Oldest Best

 

@LarsenBagley460

This seems to work pretty well:

https?://.*?(?=()|.|,|?|!|"|')*($|s))



Start with either or


https?://

...then match the shortest uninterrupted string of any characters
-.*?
...that is followed by, but doesn't include


the (?= ) "positive lookahead"

...zero or more of any common punctuation - ) . , ? ! and any type of single or double quotation mark, curly or straight, left or right


()|.|,|?|!|"|')*

...and then either the end of the paragraph or any type of whitespace


($|s)



Some testing:

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme