On 2013-12-10 16:18, Peter Danecek wrote:
> I would like to count the occurrences of a character, more specifically of
> the `.` in the ${version} option. Asking Big Brother Google, there seem to be
> quite some possibilities, so I came up with the following solutions:
>
> set dot_count [ regsub -all "\\." ${version} {} ignore ]
You won't need the substitution, so regexp should do.
set dot_count [regexp -all \\. $version]
Another way would be splitting on the delimiter and count the elements.
Of course, for the actual number of dots you need to decrement the
result by one.
set dot_count [expr [llength [split $version .]] - 1]
Rainer
_______________________________________________
macports-dev mailing list
[email protected]
https://lists.macosforge.org/mailman/listinfo/macports-dev