D
Donato Azevedo
Hi everyone,
I've got a simple question to which Ive, to this point, not been able
to solve:
I have these regexes which I want to convert into a single one:
if ( $raw_content =~ /Doc1(?:=rev)??<document1>.*?)\r\n
Doc2(?:=rev)??<document2>.*?)\r\n
Item?<item>.*?)\r\n
Data\s+doc1?<data1>.*?)\r\n
Data\s+doc2?<data2>.*?)\r\n
Obs?<observation>.*?)\r\n
Critic?<criticality>.*?)\r\n
Comments?<comments>.*)
/isx ||
$raw_content =~ /Doc1(?:=rev)??<document1>.*?)\r\n
Doc2(?:=rev)??<document2>.*?)\r\n
Item?<item>.*?)\r\n
Data\s+doc1?<data1>.*?)\r\n
Data\s+doc2?<data2>.*?)\r\n
Obs?<observation>.*?)\r\n
Critic?<criticality>.*)
/isx ) {
this is to match text that can either end in:
Critic:foobartext
or
Critic:foo
Comments:bar
The problem seems to be the greediness of the last captures: I tried
doing
Critic?<criticality>.*?)(\r\nComments?<comments>.*))?
and
Critic?<criticality>.*)(\r\nComments?<comments>.*))?
but I must be missing something... It must be something quite simple
I'd say.
Well, any ideas?
I've got a simple question to which Ive, to this point, not been able
to solve:
I have these regexes which I want to convert into a single one:
if ( $raw_content =~ /Doc1(?:=rev)??<document1>.*?)\r\n
Doc2(?:=rev)??<document2>.*?)\r\n
Item?<item>.*?)\r\n
Data\s+doc1?<data1>.*?)\r\n
Data\s+doc2?<data2>.*?)\r\n
Obs?<observation>.*?)\r\n
Critic?<criticality>.*?)\r\n
Comments?<comments>.*)
/isx ||
$raw_content =~ /Doc1(?:=rev)??<document1>.*?)\r\n
Doc2(?:=rev)??<document2>.*?)\r\n
Item?<item>.*?)\r\n
Data\s+doc1?<data1>.*?)\r\n
Data\s+doc2?<data2>.*?)\r\n
Obs?<observation>.*?)\r\n
Critic?<criticality>.*)
/isx ) {
this is to match text that can either end in:
Critic:foobartext
or
Critic:foo
Comments:bar
The problem seems to be the greediness of the last captures: I tried
doing
Critic?<criticality>.*?)(\r\nComments?<comments>.*))?
and
Critic?<criticality>.*)(\r\nComments?<comments>.*))?
but I must be missing something... It must be something quite simple
I'd say.
Well, any ideas?