Reply To: Shortest GREP Pattern to address URLs and e-mail addresses?

Home Page / Forums / General InDesign Topics (CLOSED) / Shortest GREP Pattern to address URLs and e-mail addresses? / Reply To: Shortest GREP Pattern to address URLs and e-mail addresses?

#65128
Mark Coster
Member

Hi everyone

I’m fairly new to GREP, but I started experimenting with it on the magazine that I produce and sure enough I ran into ‘The URL problem’ that everyone inevitably does! I initially came up with a fairly long code that targeted URLs that did not have ‘https://’ or ‘www.’ at the start because that was the magazine’s house style:

(\w+|\w+-|\w+/)*(\w+\.[\u]+(\.[\u]+)*)(/\w+(/w+|-\w+)*)*

But then I looked at the problem again and tried to simplify each element until I got the following:

([^]+)\.([^]+)

This (as far as I can see with the testing I have done so far) finds any url irrespective of what’s in it. I tested it on Casey’s sample text in his post and it makes the same matches (unless I missed something). I’d love any feedback or suggestions of how to improve it. I also posted this on my own blog (https://www.pixooma.co.uk/blog/2013/08/31/url-grep-simplified/) as I’d like to come back to this topic regularly.

Mark

This article was last modified on August 31, 2013

Comments (0)

Loading comments...