Friday, May 04, 2007

[code] Regexp with exception for extension

Queston: What's the regexp that would match: "/foo", "/bar", etc.

But would not match "*.txt", "/foo/*.txt", "/foo/bar/*.txt", etc.

Answer: /\/(\w*|^.txt)$/

(Courtesy of Serge)

No comments:

Post a Comment