Re: simple regex for highlighting _/* fails

Urs Janßen <[email protected]> Sat, 7 Apr 2007 00:13:52 +0200
Newsgroups gmane.network.tin.user
Message-ID <[email protected]>
On Fri, Apr 06, 2007 at 05:41:51PM +0200, Rado S wrote:
> > (^|[[:space:]'"(])_[^[:space:]_][^_]*[^[:space:]_]_([[:space:]'").,:!?]|$)
> > However, this fails in tin, but I don't understand why.
> The funny thing is:
> after I played around a bit with it, I found this to work:
> 
> (^|[[:space:]'"(])_[^[:space:]_][^_]*[^[:space:]_]_[[:space:]'").,:!?]
> 
> I.e. I dropped the () at the end (with the alternative of being EOL).
> 
> What's so problematic about having () at the end?!

(empty) capturing subpatterns (yes, this is a bug in the code - feel free to
fix it). use (?:) instead of (), e.g.

(?:^|[\s'"\(])_[^\s_][^_]*[^\s_]_(?:[\s'"\)\.,:!\?]|$)

\s is a shorthand for [:space:] and litteral ().? should be quoted for
clearness

urs
-- 
"Only whimps use tape backup: _real_ men just upload their important stuff
 on ftp, and let the rest of the world mirror it ;)" - Linus