I have a string which contains data of a person delimited by '%'. The third field in the string represents 'ID' tag,
I want to extract all thr names which has ID tag starting with 'A'.
For example $data variable may contain :
$data = "Johnson%Andrew%AX321%Engineer" ;
$data = "Smith%John%BC142%Alberta";
I am using :
print "$2 $1\n" if m/^(.*?)%(.*?)%A/;
But this is giving me
Andrew Johnson ## output Ok
John%BC142Smith ## Wrong
But I don't want this. The second half of the regex does not say match up to next % and then match 'A'. Instead it says match upto the next % which is followed by 'A'.
Hence for the second $data it is getting past the second % and fetching John%BC142Smith