substitute "\s" with "*" to make split easier sounds like a very bad idea.
didn't see people doing that in perl.
problem is solved, why do you add extra complexity?

On 1/19/07, Michael Alipio <[EMAIL PROTECTED]> wrote:



----- Original Message ----
From: I.B. <[EMAIL PROTECTED]>
To: begginers perl.org <beginners@perl.org>
Sent: Saturday, January 20, 2007 1:02:39 PM
Subject: Re: Selective splits... (treat this "pattern" as a delimiter only
if it is followed by this "pattern")

> you can use lookaheads:

> my @matched = split /\s+(?=\w+=)/,$string;

I've already figured that out, but there's one problem  I encountered:
What I did was to modify the entire line first and substitute all necessary
\s+. with '*' so that splitting will be easier.

Those \s+ were:

all spaces if the following word is not either date or time and also all
spaces if the following word is \w+=

My regexp looks like this:

$_ =~ s/\s+(?!(date|time))/*/g ;

Now, having a problem where to put my parenthesis to add the "?=\w+="
condition..
Can you help me with this? I tried several times but I failed.

Thanks.






> cheers,
> ~i

On 1/19/07, Michael Alipio <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Suppose I have:
>
>
> my $string = 'Jan 19 11:37:21 firewall date=2007-01-19 time=11:42:15
devname=TESTfirewall device_id=FGT-602905503304 log_id=0104032006 ty
> pe=event subtype=admin pri=information vd=root user="admin"
ui=GUI(192.168.1.1) action=login status=success reason=none msg
> ="User admin login successfully from GUI(192.168.1.1)"
> ';
>
>
> That is, on a regular \s+ split, I will produce this list of strings:
> Jan
> 19
> 11:37:21
> firewall
> date=2007-01-19
> time=11:42:15
> devname=TESTfirewall
> device_id=FGT-602905503304
> log_id=0104032006
> type=event
> subtype=admin
> pri=information
> vd=root
> user="admin"
> ui=GUI(192.168.1.1)
> action=login
> status=success
> reason=none
> msg="User
> admin
> login
> successfully
> from
> GUI(192.168.1.1)"
>
> However, I only want to split it with \s+ as delimiter, only if that \s+
is followed by "\w+=" so that the: 'msg="User admin login successfully from
GUI(192.168.1.1)" will not be splited.
>
> I tried putting parenthesis in my split pattern:
>
> split/(\s+)\w+=/, $_
>
> So that it will only split the line delimited by space if it is followed
by any "\w+=" just like when doing a regexp matching.
> But the program treats \w+= as part of the whole pattern so instead of
getting:
>
> date=2007-01-19
>
> time=11:42:15
>
> devname=TESTfirewall
>
> device_id=FGT-602905503304
>
>
> I got:
>
> 2007-01-19
>
> 11:42:15
>
> TESTfirewall
>
> FGT-602905503304
>
>
> Any idea how to accomplish my goal?
>
>
>
>
>
>
>
>
>
>
____________________________________________________________________________________
> It's here! Your new message!
> Get new email alerts with the free Yahoo! Toolbar.
> http://tools.search.yahoo.com/toolbar/features/mail/
>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




 ________________________________
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to