Here is a shot and I am just printing. You could substitute for the while an
Arra:

#!perl -w
$string1 = "[%a %H:%M:%S %c] - - etc.etc.etc";

while ( $string1 =~ /(%.)/ig ) {
    printf "%-s\n", $1;
 }


If you want to capture to an array:

my @array = $string1 =~ /(%.)/ig;

foreach ( @array ) {
    printf "%-s\n", $_;
 }

Output was:
Print:
%a
%H
%M
%S
%c
Capture, then print:
%a
%H
%M
%S
%c
-----Original Message-----
From: Craig Moynes/Markham/IBM [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 07, 2001 12:28
To: [EMAIL PROTECTED]
Subject: Parsing a string....


Ok I know I know how to do this but I just can't get it out of my brain

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)

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.

All I actually need is the single character following each '%' sign, but I
can do that stage on my own :)

thoughts, solutions, manpages to look at ...all are appreciated.

thanks all

-----------------------------------------
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
[EMAIL PROTECTED]

Reply via email to