Reply To: The perfect GREP pattern for URLs

Home Page / Forums / General InDesign Topics (CLOSED) / The perfect GREP pattern for URLs / Reply To: The perfect GREP pattern for URLs

#55192

There is no such beast :P

Every time I thought I found “the definitive GREP” something else popped up — latest major addition was support for “?” queries, and that opened another can of snakes. Best you can hope for is “something that works 80% of the time”, I think.

As for Casey's problems,

Some issues that came out of Casey's post were (1) avoiding the full-stop if the URL is at the end of a sentence, and (2) including any slashes that appear at the end of a URL.

(1) No problem if you only allow a period inside, that is, it always should be followed by a alphanumeric.

(2) Also no problem — all you need to do is end with “/?”

You can build something up from this, for starters:

(http|ftp)://[a-zA-Z][a-zA-Z0-9]+.([a-zA-Z_0-9]+.)+[a-zA-Z_]+(/[a-zA-Z_0-9.]+)*/?

– it found all 7 URLs in the document I happened to have on my screen right now.

(Ed. Hah. Didn't address Casey's #1 — never allow a period end. Some shuffling around will solved that, tho'.)

This article was last modified on March 18, 2010

Comments (0)

Loading comments...