"Craig Moynes/Markham/IBM" <[EMAIL PROTECTED]> wrote:
>I have a string like this:
>$string1 = "[%a %H:%M:%S %c] - - etc.etc.etc";
>I need to parse out all the substrings that are similar to "%x" (where x is
>any letter)
Use a global pattern match in array context:
@matches = $string1 =~ /%[A-Za-z]/g;
>I have thought about tackling this using the regexp (%\w) using the
>grouping and getting each match with $n (where n is a number) but I can't
>seem to get the regexp to match more than the first match.
Note that \w will match digits and '_', while you said you wanted only
letters.
>All I actually need is the single character following each '%' sign, but I
>can do that stage on my own :)
You can grab just the single characters with a negative lookbehind
assertion (man perlre):
@matches = $string1 =~ /(?<=%)[A-Za-z]/g;
--
Sean McAfee [EMAIL PROTECTED]
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!