Q
QoS
Hello, having some trouble solving this regular expression puzzle.
It is possible to solve the issue using some if statements, but im
curious why this is occurring.
The data involved looks similar to the following:
ALWAYSPRESENT:0008:0:OPTIONAL
OPTIONAL
OPTIONAL
Where the data will always start with a name.
This is followed by a colon some numbers a colon some numbers and a colon,
which will all be discarded.
Then there may or may not be some additional data after that.
Next there might be a newline followed by some optional data.
Finally there might be a newline followed by some optional data.
Ok here is my issue, the RegEx im using to do this will place data found
in the 3rd memory variable in the variable $4 when there is no match
to fill $4. So $4 will contain data but $3 will not, when i expected rather
that $3 would contain data and $4 would not.
Example troublesome data:
ALWAYSPRESENT:0008:0
RESENT
PRESENT
NOTPRESENT
This is the offending RegEx.
$msg =~ /(.*?):.*
.*)\n*(^.*)\n*(^.*)/m;
Thanks for any assistance.
It is possible to solve the issue using some if statements, but im
curious why this is occurring.
The data involved looks similar to the following:
ALWAYSPRESENT:0008:0:OPTIONAL
OPTIONAL
OPTIONAL
Where the data will always start with a name.
This is followed by a colon some numbers a colon some numbers and a colon,
which will all be discarded.
Then there may or may not be some additional data after that.
Next there might be a newline followed by some optional data.
Finally there might be a newline followed by some optional data.
Ok here is my issue, the RegEx im using to do this will place data found
in the 3rd memory variable in the variable $4 when there is no match
to fill $4. So $4 will contain data but $3 will not, when i expected rather
that $3 would contain data and $4 would not.
Example troublesome data:
ALWAYSPRESENT:0008:0
PRESENT
NOTPRESENT
This is the offending RegEx.
$msg =~ /(.*?):.*
Thanks for any assistance.