Trouble With Textile

As I was writing that last entry (about the Hannibal Trilogy) I was having some trouble with the way Textile was handling URL catching. The issue was that whenever I wanted to use an address with numbers at the end, those trailing numbers would not be included as part of the address. Here is the original code for cathing the URLs:


'/

# 1 optional space or brackets before
([\s[{(]|[[:punct:]])?

#   starting "
"

# 2 text of link
([^"\(]+)

#   opt space
\s?

# 3 opt title attribute in parenths
(?:\(([^\(]*)\))?

#   dividing ":
":

# 4 suppose this is the url
(\S+)

# 5 opt trailing slash
(\/?)

# 6 opt punctuation after the url
([^[:alnum:]\/;]|[1-9^]*)

# 7 either white space or end of string
(\s|$)

/xU'

After playing around with various things, I narrowed the problem down to item 6. I got it down to a form that now seems to work:


([^[:alnum:]\/;]?)

This change does not appear to affect the normal usage so I’m guessing its a safe change. However I’m no wiz when it comes to regular expressions so I’m not sure how this might affect future functionality. I’ll keep an eye on it.

Comments are closed.