vercmp with "-" [SOLVED]

Bradley Giesbrecht pixilla at macports.org
Sun Dec 18 09:47:58 PST 2011


On Dec 18, 2011, at 7:41 AM, Rainer Müller wrote:

>> The code that before worked did this:
>> 
>> -                        if {[regexp $the_re $line matched upver]} {
>> 
>> "matched" is the entire string matched, and "upver" is the first
>> parenthesized expression. Any additional parenthesized expressions
>> are ignored.
> 
> Okay, that's the problem. I did not think of a regex with multiple
> groups. Thanks for chasing this one down.

...
> So, if
> we find out how many parentheses the regex will produce, we can remove
> this many items from the returned list in each loop iteration but only
> use the first one as the matched version. This would be easier than
> algorithmically modifying the regex.
> 
> An alternative would be to use the -indices option of regexp which
> returns the position of the match in the string. Then the regex could be
> applied multiple times using -start to begin matching where the previous
> match ended.

With the -indices option, would the intent of the code be more obvious?

Regards,
Bradley Giesbrecht (pixilla)






More information about the macports-dev mailing list