in reply to Regular Expression Help

that is easy.
$/=""; while (<DATA>) { /^([^,]+,[0-9]+)/; $a = $1; @a = /(CN=[^,"]+)/msg; print qq($a,"), join(", ", @a), qq("\n\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"
Output:
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=Raim +un Sirilo, CN=Amilcar Ove, CN=Paula Corte" Human_Resources,3,"CN=Katarine Gilly, CN=Chris Head, CN=Susany Cadru"
hint:
if one regex gets to complicated: split it up.

Replies are listed 'Best First'.
Re^2: Regular Expression Help
by Anonymous Monk on Jan 13, 2005 at 15:30 UTC
    Actually was my fault to forget to say that sometimes the data will have lines that doesn't match the ones a have here, and them the code breaks, unfortunately, just because it is looking for a space between the lines separating wach block.
      how do these lines, look? Would you please provide an example.