Hi,
I tried to write a script to extrat data from the given DATA but I can find
the right regular expression to do that.
RULE: I need to catch everything between quotes (single or double) and if
inside exists a repeated quote (single or double) it is not seen as end of
the match.
#!/usr/bin/perl -w
use strict;
my $begin = '[\",\']'; #
my $end = '[\",\']'; #
my $pattern = "${begin}(.*?)${end}"
while (<DATA>) {
print "line content $_ \n"
while ( /$pattern/g ){
print "line $. found : $1\n"
}
}
__DATA__
' data11 '' data12' 'data13'
" data21 "" data22" "data23"
" data31 '' data32" "" "data34"
"data41" "data42" "data43" "__--data44"
"""" "''" '""' ''''
Result should be
1:( data11 '' data12)
2:(data13)
3:( data21 "" data22)
4:(data23)
5:(data31 '' data32)
6:()
7:(data34)
8:(data41)
9:(data42)
10:(data43)
11:(__--data44)
12:("")
13:('')
14:("")
15:('')
It could be resolved by replacing the \"{2} or \'{2} by a "[EMAIL PROTECTED]" and
alterwards relacing it back to the previous value but it is not very smart.
great thanks in advance
Michel
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]