On Wed, Apr 02, 2003 at 12:45:37PM -0500, Yacketta, Ronald wrote:
> I have hit a minor brain road block here, trying to regex out a line
> containing all text up to the first .
>
> Line looks like this:
>
> <04/01/03 16:36:21.737 [blah]>|blah(): Throw blah from idl method: Number:
> 6048 Reason: blah failed: blah. blah. - OrderNumber <blah> blah
> WorksheetNumber <blah> SR WorksheetNumber <blah> failed
>
> Here is my regex
>
> push( @errors, $1) if ( $_ =~ /^<$g_date.*method: (.*\. )/ );
>
> What I am seeing is
>
>
> Number: 6048 Reason: blah failed: blah. blah.
>
> When I should be getting
>
> Number: 6048 Reason: blah failed: blah.
This is because of the "greediness" of *: It gobbles up all it can.
You could either use a "non-greedy" match (.*?), or you could use a
character class instead of the ".".
That would give you
/^<$g_date.*method: (.*?\. )/
or
/^<$g_date.*method: ([^.]*\. )/
I'm not sure if there is any difference between those two
performance-wise. They should do the same thing anyhow.
HTH,
Elias
--
If Jesus was Jewish, then why did he have a Puerto Rican name?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]