The * operator is greedy, grabbing as much of the string as it can with
still being able to match. The ? operator limits this behavior, so I think
what you want is:
$String =~ /^(.*?):/;
/\/\ark
-----Original Message-----
From: Russ Foster [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 2:10 PM
To: '[EMAIL PROTECTED]'
Subject: Regular Expressions - matching the first time
I have string, something like:
$String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti:
qwiojd";
Now, I want to extract everything from the start of the string, up through
the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this:
$String =~ /^(.*):/ ;
So: ^ starts at the beginning, (.*) to grab everything in the middle, and :
to match the colon.
What I am getting is, everything from the start of the string up until the
last colon. In this example:
$1 = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti"
What I want is:
$1 = "aaa bbb"
I even tried using:
$String =~ /^(.*):{1}/ ;
Thinking the {1} would match the first occurance of :, but that didn't
change the results (I was runningn out of ideas).
Now, I could split $String on :, but I have to think that there is a better
way and I'm missing some modifier that I can't find in the FAQ or any of the
three books that have been dumped on my desk.
Any help is appreciated.
Russell J Foster
Subject, Wills, & Company
e. [EMAIL PROTECTED]
v. 630-572-0240
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]