Hi Monks, I need to get rid of some data inside quotes and I am having problems because the string has multiple line so on the next interaction it is picking up on the wrong thing, any help will be great.

And here is the code with some data and sample of what the results should looks like.
Thanks again!

#!/perl/bin/perl use strict; use warnings; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); print header(); while (<DATA>) { chomp; if (/CN=\w+/) { #$_ =~ s/^(.+?"CN=.+?),.+$/$1"/; $_ =~ s/^(\w+\s,\d+,"CN=.+?),.+$/$1"/; print "$_\n"; } } __DATA__ DHCP Administrators,2,"CN=May Mary,OU=Enterprise Admins,Users,DC=INTER +NETNET,DC=com Domain Admins,Users,DC=INTERNETNETCOM,DC=com",, DnsAdmins,2,"Enterprise Admins,Users,DC=INTERNETNET,DC=com CN=Arth Gure,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Domain Admins,Users,DC=INTERNETCOM,DC=com",, AS400 Query Database,2,"CN=Joe Car,OU=Systems/Operations,OU=MIS,OU=Use +r Accounts,DC=INTERNETNET,DC=com CN=Ricrad Tallar,OU=Systems/Operations,OU=MIS,OU=User Accounts,DC=INTE +RNETNETCOM,DC=com",, Deptpar Access,8,"CN=John Class,OU=Marketing,OU=User Accounts,DC=INTER +NETNET,DC=com CN=Judy Lipa,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com CN=George Grey,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Artur More,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com CN=Raimun Sirilo,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com CN=Amilcar Ove,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Daniel Santos,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com CN=Paula Corte,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com" Human_Resources,3,"CN=Katarine Gilly,OU=Executive,OU=User Accounts,DC= +INTERNETNET,DC=com CN=Chris Head,OU=Human Resources,OU=Finance & Administration,OU=User A +ccounts,DC=INTERNETNET,DC=com CN=Susany Cadru,OU=Human Resources,OU=Finance & Administration,OU=User + Accounts,DC=INTERNETNET,DC=com" =commnet Here are what I am expecting to get back: DHCP Administrators,2,"CN=May Mary" DnsAdmins,2,"CN=Arth Gure" AS400 Query Database,2,"CN=Joe Car,CN=Ricrad Tallar" Deptpar Access,8,"CN=John Class,CN=Judy Lipa,CN=George Grey,CN=Raimun +Sirilo,CN=Amilcar Ove,CN=Paula Corte" Human_Resources,3,"CN=Katarine Gilly,CN=Chris Head,CN=Susany Cadru" =cut

In reply to Regular Expression Help 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.