in reply to regexp in win32

I think you want to replace
(\s*) }xm
with
\s* (.*) }xm
The 'm' switch has no effect in that regexp, but it doesn't hurt either.

Update: Does your input span two lines? I couldn't tell before Corion added <code> tags. If so, you'll need something like:

while (<>) { my @fields; if (@fields = m{ \[ (\w{3}) \s* (\w{3}) \s* (\d{2}) \s* (\d{2}:\d{2}:\d{2})\s* (\d{4}) \] (\w*) \/ (\w*) /// Info(\(\d*\)) }xm) { push(@fields, scalar <>); print(join("\n", @fields)); } }

Update: Fixed error in join.

Replies are listed 'Best First'.
Re^2: regexp in win32
by lorn (Monk) on Nov 16, 2005 at 19:02 UTC

    with

    \s* (.*) }xm

    dont work, dont show any data of the sencond line :/ and i dont understand you solution

    Lorn -www.slackwarezine.com.br-

      OK, so you can either (a) parse both lines in succession with two different regular expressions (or one very flexible one) or (b) you can join the lines together (with or without the carriage return) and parse the line once. I recommend (b), but if you decide to leave the \n inside your string, you'll want to use the /s flag on your regex. Maybe something like this:
      my $buffer = undef; while (<YOURFILE>) { $buffer .= $_; } if ($buffer =~ /your regex/s) { # do stuff with $1 ... etc. }

      I had join's parameters backwards. Fixed. Tested. Works.

      The test:

      The output:

      Fri Sep 30 14:02:22 2005 Local ESSBASE0 (1051001) Received client request: Logout (from user Procbat)

      (Changed <> to <DATA> for test.)