in reply to Extract data from regex match where "." is newline?

Second the motion from Deacon Eliya ...even after putting the /g back into the mix:
#!/usr/bin/perl use Modern::Perl; # 943829 my $str = "<Master ID='foobar\nblivitz' NameUI='12345'"; if ( $str =~ /<Master ID='(.*?)' NameUI='(.*?)'/sg ) { say "\$1: $1"; say "\$2: $2"; }else{ say "WTH?" }
Prints:
$1: foobar blivitz $2: 12345
So,
  1. Have you looked rilly, rilly carefully at the source data? For example,
        Characters? Character encoding? Tabs masquerading as spaces?
        Spurious appearance as if newlines were present because of wrap-on-render?
        Anything else?
  2. Any possibility that you have a quoting problem when you tell your regex to test $text?
  3. And, precisely, where are the newlines that you think are giving your trouble?

Please, post a sample, wraped in <code>...</code> tags

Replies are listed 'Best First'.
Re^2: Extract data from regex match where "." is newline?
by dsayars (Initiate) on Dec 17, 2011 at 06:10 UTC

    Thanks to Eliya, muba and ww. It turned out the Perl solution was not a Perl solution. I discovered by accident that the unwanted newlines could be removed by saving the Visio .vsx (stencil) file to a Visio.vdx (drawing) file. (Simply removeing all newlines was no good because it created one long 70-Mb line.) Since you are a religious order, you will be want to know what moral lesson I drew from this. It is that the tool you used to create the file on which you are going to run Perl often has the means to make the file more presentable to Perl, which is to say more worthy of Perl.