Eric Walker wrote:

I am trying to search a string for a "[]". I want to count the amount
of "[]" in the string.


Any IDeas....






re my first post on this, here is a better (well, Lazier) way:

$string = "a4r[]qy78[]x]y[114[[[[[[|]]]]]]t";
$count = $string =~ s/(\[])/$1/g;
print "$count\n";

# $count is the number of times the desired expression (DU) appears in the search string
# $string is the string to be searched
# the regex substitutes the DU for itself. Utterly useless, but a side-effect is that the number of substitutions performed is stored in $count.
# the $1 variable is a placeholder, it saves you the effort of typing the DU twice and possibly making a mistake




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to