This is my first post to SoPW, though I've had solid success using the CB.

I work with lots of text files and have had problems with the perl mods ie Text::CSV_XS etc... do not allow for embedded non-escaped text qualifiers or field seperators. So this is an attempt to retrieve the text qualifier and field seperator from a text file containing a header.
$foo = qq{^snafu^|^foobar^\n}; $foo =~ m/\A(\W) # \A instead of ^ and match first non-word [^\1]+ # Match everything that isn't in \1 \1(\W) # Match non-word following the 2nd \1 /xms; $text_qual = $1; $field_sep = $2;
The regular expression is setting the second match to newline instead of pipe as it should.
It appears as if [^\1]+ is being interpreted as .+ for some reason? Obviously in this case I could use
$foo =~ m/\A(\W) # \A instead of ^ and match first non-word \w+\1 # Match any word char until the next \1 (\W) # Match following non-word /xms;
But this only works for this limited case where the first field contains no symbols. Any suggestions would be greatly appreciated.

MajingaZ
~Sic volere parcas~
So spin the Fates

In reply to Regular Expresssion TroubleShoot Help plz by MajingaZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.