Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Dealing with Regexes for a specific replacement pattern

by gridlock (Novice)
on Feb 21, 2004 at 04:55 UTC ( #330767=perlquestion: print w/replies, xml ) Need Help??
gridlock has asked for the wisdom of the Perl Monks concerning the following question:

I've been dealing with this problem which has gotten me stumped - and I figure there has to be a way to do this simply with a regex rather than write a seperate function.... here's my jam...

I've had to deal with a stack of values who's occurrence is as follows:


Now - the trifle is as follows.....
This is a stack of values that are all delimited by the character "C". However, for all fields beginning with "338" - there is no field delimiter - the values starting with 338 have a standard format as follows:


What I want to do is replace this pattern with the same pattern with a C appended to it within the string... so I tried using the follwing regex:

s/338C\d\d\dC\d\d\dC\S\S\S\S\S\S\S\S /338C\d\d\dC\d\d\dC\S\S\S\S\S\S\S\S C/g

The only problem is.... although it inserts the "C" delimiters, the regex has wipes out the pertinent data of the digits and the "F"s - - is there a simple regex I can use to accomplish this? Any help will be much appreciated! Thanks is advance!
/Gridlock a.k.a. Debashis "Codito Ergo Sum"
  • Comment on Dealing with Regexes for a specific replacement pattern

Replies are listed 'Best First'.
Re: Dealing with Regexes for a specific replacement pattern
by jweed (Chaplain) on Feb 21, 2004 at 04:57 UTC
      Or even simpler:


        Thanks much! Appreciate it!
        /Gridlock a.k.a. Debashis "Codito Ergo Sum"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://330767]
Approved by jweed
[shmem]: tell them
[Discipulus]: nettop I have some spare time..
[Discipulus]: do you have some spare money? ;=)

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2018-04-20 17:28 GMT
Find Nodes?
    Voting Booth?