From: Rob Biedenharn Date: 2007-03-31T01:17:57+09:00 Subject: Re: Regex Black Magic... how to stop matching if char? On Mar 30, 2007, at 11:43 AM, Jon Fi wrote: > Robert Klemme wrote: >> On 30.03.2007 17:34, Jon wrote: >>> >>> >>> >>> >>> ..because there is no gauranteed whitespace between tags. >>> Basically, I >>> need to stop matching if a ">" is found. I've never had to deal with >>> anything quite like this in my regex experience. Any help or >>> thoughts of >>> a better way to do things is much appreciated! >> >> I can think of several solutions: >> >> /<([^>\s]+)\s+(\d+):(\d+)>/ >> >> Or even a two phased approach >> >> /<[^>]+>/ >> >> and then with the match >> /(\d+):(\d+)>\z/ >> >> HTH >> >> robert > > > awesome, and thank you! but for my benefit, could you explain why that > works? I thought ^ was line start? Within a character set it inverts the selection so [^>] matches any character that's NOT a '>' My solution is: .gsub(/<([^>]*?\b\s+)(\d+):(\d+)>/, '<\1no="\2" of="\3">') -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com