Murali_Newbee has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
I wish everyone a very happy new year, The following is my question:
I have a file in which data consists in the following format
line1= alphanumeric_word|group=.,name1,name2,name3|pid=.,name1,name2,name3
note: here if ids are present in group then group starts as |group=.,name1,name2,so on,name'n'| else if ids are not present then |group=.| (same applies for pid)
line2= alphanumeric_word|group=.|pid=.,name1,name2
line3= alphanumeric_word|group=.,na-me1,na-me2,name3|pid.
Example input file :
bbias123|group=.,zdfep,hbfg|pid=.,bvg,klep
vbsxs4062|group=.,pbsg,zlkdpep|pid=.,zcsep,pvsw
ghbv2416|group=.|pid=.,zidsxdq,dsasm
hexli217|group=.|pid=.,dsdm,zfsddq
iiutdx34396|group=.,swdg|pid=.,trdsdg
lmadnx50|group=.,rtgqa,dsdaaad-ds,dsav,dsddod,dasd-dgjeod,lagx,cntrlg|pid=.,ddwx,cntrlg
vvssdes12451|group=.,cntrlg,pasg,gsfbal-cpg-drtsess-prod,cpdsx,global-dsxf,ghkxjsk-tucx|proid=.,pasg,zlntrg
vmias1132952|group=.,cpgqa,gldsal-cpg-dsxw-tdx,pasg,gl-cpg,global-cpg-access-prod,cgrtrg,cpgdsod|pid=.,pasg,cmttgr
vmias1132953|group=.,cntrlg,paes,glods-cpdsd-tdk-tja,cpgprod,gvdf-sdsg-dsx-tr,gjxb-ghmsl-sut,dsdsws|proid=.,pasg,zlntrg
desired output from each line:
alphanumeric_word.groupid1
alphanumeric_word.groupid2
alphanumeric_word.pid1
alphanumeric_word.pid2
< note : if group doesn't consists of any id's then it should skipt group and print alphanumeric.pid1,alphanumeric.pid2 etc (same applies for pid)desired output example:
bbias123.zdfep
bbias123.hbfg
bbias123.bvg
Kindly help me, thank you Monks :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex to extract alphanumeric strings between pipe delimiter
by haukex (Archbishop) on Jan 11, 2019 at 08:16 UTC |