Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^5: regex optional word match

by marto (Bishop)
on Jul 26, 2012 at 10:59 UTC ( #983827=note: print w/replies, xml ) Need Help??

in reply to Re^4: regex optional word match
in thread Parsind data in xlsx

In case you missed my message, please use code tags when posting code and data. This advice is displayed each time you post:

<code> code/data here </code>

See also How do I post a question effectively?.

Replies are listed 'Best First'.
Re^6: regex optional word match
by Rahul Gupta (Sexton) on Jul 26, 2012 at 11:31 UTC

    Sorry Guys,I am new here.
    I have one array with 2 Strings:

    String1: "REMOTE [Mon Jul 16 21:49:33 2012] @@ [ueh1] [TNT] [2049 +0] [1916] 0.0- 1.0 sec 0.33 MBytes 2.74 Mbits/sec 6.056 ms 0/ + 233 (0%)". String2: "REMOTE [Mon Jul 16 21:49:34 2012] @@ [pdn1] [SSH] [2049 +9] [3] 1.0- 2.0 sec 0.34 MBytes 2.86 Mbits/sec".

    In "String1" I have two extra values that is "6.056 ms" and "0/ 233 (0%)" and rest are same in both string.
    I tried this regex:

    <m/^REMOTE\s+\[(.*?)\]\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+\[(.*?)\]\s+ +(.*?)sec\s+(.*)MBytes\s+(.*)Mbits\/sec>
    but need to add the above mentioned two values of String1 in regex and make them optional so that both condition gets passed and last values stored in $1, $2, $3 and so on.
    Can anyone help me?
    Thanks in advance

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://983827]
[Discipulus]: pps this is the chatterbox, not the search. here we have Super Search

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-04-27 16:54 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (512 votes). Check out past polls.