Hi all, I need help with some regular expressions. I'm trying to match the table and view names and the tables and view in the from section of a SQL statement. The problems include: - that the spacing can be irregular - They can go over the a single line - can be mixed casing I can match the names with different regular expressions, but I'm wondering if it's possible to merge them? What about the from clause? How do I strip them out over the multiple lines? I think I will need to parse the scripts twice to get the different part and change the paragraph symbol.
create view V_PAID_USERS as select * from users u, subcription s where u.user_id=s.user_id and s.balance =< 0; CREATE OR REPLACE VIEW V_OVERDUE AS select * from users u, subscription s where u.user_id=s.user_id and s.duedate > 60; create TABLE UNPAID_USERS as select * from users u, subcription s where u.user_id=s.user_id and s +.balance > 0; create view receipts as select * from unpaid_users; Here's the code: if($_ =~ /create\s/i .. /V_\w+/i) { if($_ =~ /(V_\w+)/i) { print OUTFILE "$path Line: $line_cnt: $1\n"; } } if($_ =~ /create\s/i .. /T_\w+/i) { if($_ =~ /(T_\w+)/i) { print OUTFILE "$path Line: $line_cnt: $1\n"; } }

In reply to Pattern matching "dirty" data sources by Anonymous Monk

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.