troubleshooting Question

reg ex replace multiple lines

Avatar of GessWurker
GessWurker asked on
Perl
1 Comment1 Solution191 ViewsLast Modified:
I need a regex (and more) so that I can take input like this:

Id 33759
Auth1Name Smith, Fran F.
; Johnson, Marty A.
; Erikson, Elaine Ann
$


search for the semi-colons at the beginnin of lines and -- if found -- output this:
Id 33759
Auth1Name Smith, Fran F.
Auth2Name Johnson, Marty A.
Auth3Name Erikson, Elaine Ann
$

There can be up to 7 authors, so we could end up with this input

Id 33759
Auth1Name Smith, Fran F.
; Lastname2, Authur B.
; Lastname3, Authur
; Lastname4, Authur J.
; Lastname5, A. C.
; Lastname6, Authur A.
; Lastname7, Authur
$

Id 33759
Auth1Name Smith, Fran F.
; Lastname2, Authur B.
; Lastname3, Authur
; Lastname4, Authur J.
; Lastname5, A. C.
; Lastname6, Authur A.
; Lastname7, Authur
$

which should output as

Id 33759
Auth1Name Smith, Fran F.
Auth2Name Lastname2, Authur B.
Auth3Name Lastname3, Authur
Auth4Name Lastname4, Authur J.
Auth5Name Lastname5, A. C.
Auth6Name Lastname6, Authur A.
Auth7Name Lastname7, Authur
$

Any takers?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros