|Problems? Is your data what you think it is?|
Regex with conditionby OldChamp (Acolyte)
|on Nov 18, 2015 at 22:44 UTC||Need Help??|
OldChamp has asked for the wisdom of the Perl Monks concerning the following question:
Sorry for obviously not describing my problem clear enough, so here is the updated Question.
I can use perl 5.010 and there is no problem in reading the complete inputfile in memory.
I have text in a file of the following form, where the dots stands for a random amount of other text. After reading the input-file, all the newline characters are removed and my text is in $line.
If I have a space, followed by the letter b, followed by another space, as shown here in the third line, I want to substitute only the following 'Weiss' with 'Schwarz' and then continue to go through the text until there is another occurence of the pattern (space, followed by the letter b, followed by another space), when the next substition should follow.
So the core of the problem is: If I find a certain pattern-1 in the text, then go on till I find a certain pattern-2 and substitute this with a pattern-3. Do this again for the whole text. I have tried the following:
but neither of this gives me the desired result, the text didn't change. How to solve this problem?