Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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
NodeReaper power washes the cellar floor

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2018-07-22 09:24 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (453 votes). Check out past polls.