Win has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Regex problem II
by Tanktalus (Canon) on May 10, 2007 at 21:55 UTC

    That's not a regexp question, that's a Text::CSV (or Text::CSV_XS, or my personal favourite, DBD::CSV) question.

    Once you have your field split, it's much easier to match. Or, using DBD::CSV, you could just say "SELECT col2 WHERE col1 = 'Indicator'" (substitute in the correct column names), and then you could use a much simpler regexp to pull out the info you want from there. (The quotes, if any, would already be stripped by this point.):

    if ($field1 =~ /^(.*?)(\([^)]*\))$/) { print OUTFILE_B "$1\t$2\t"; }
    But I'm an SQL nut.

Re: Regex problem II
by daviddd (Acolyte) on May 10, 2007 at 18:21 UTC
    Your sample line has a colon (:), but your regex does not account for the colon. I was able to get a match once I added it.
Re: Regex problem II
by halley (Prior) on May 10, 2007 at 17:12 UTC
    I'm completely baffled at why your regex wouldn't work perfectly, since your sample data line definitely does begin (^) with the given literal (Indicator,"), and so on.

    Oh, wait. No, your sample data line begins (^) with a different literal (Mortality from pneumonia). Now it makes sense.

    Update: Okay, now you provide a completely different input line. But it still doesn't have the literal double-quote which you are trying to match in the pattern. See the \" in your pattern? Every literal character in the regex pattern must match exactly in the input, or it will fail the match.

    --
    [ e d @ h a l l e y . c c ]

      it still doesn't have the literal double-quote which you are trying to match

      I realise that Win's habit of updating his posts willy-nilly may have altered the sense of the OP silently but, from what I am seeing now, he did make the literal double-quote optional with a {0,1} quantifier. Do we have any computer forensics specialists in the Monastery?

      Cheers,

      JohnGG

        "Do we have any computer forensics specialists in the Monastery?"

        Sort of :)

        Martin
Re: Regex problem II
by ww (Archbishop) on May 10, 2007 at 17:41 UTC
    Your update obfuscated rather than helped. Now there's no "Mortality from pneumonia and (ICD10 J12-J18)" left in the test line.

    Suggest that you use <strike> ... </strike> around what you want delete from your statement of the problem, instead of actually deleting it.