07-05-2013, 03:40 AM
I have a big multi line string which contains line-break characters "[ ]" (carriage return+linefeed)
And I want to do 2 type of replacements
1) Cycle through every "line" and replace every "line" that begins with "x" or "y" with "1234"
xbbb and yccc are replaced with 1234
2) Target a specific "line number", => line 3 "yccc" and replace it with "1234"
Macro Macro28
I have done this easily by putting the string in an array. But is it possible to do the replacements I described above by manipulating string "s" only.
With "putting the string in an array" I mean like this:
arr[0]=aaa
arr[1]=xbbb
etc...
I do not know if I am using the correct terminology when using the terms like "line" and "line number", because the string does not contain line-numbers or lines. From the help-file "A string is an array of characters.". But I still used these terms to describe the problem and the desired output.
And I want to do 2 type of replacements
1) Cycle through every "line" and replace every "line" that begins with "x" or "y" with "1234"
xbbb and yccc are replaced with 1234
2) Target a specific "line number", => line 3 "yccc" and replace it with "1234"
Macro Macro28
str s="aaa[]xbbb[]yccc[]ddd[]eee[]ffff" ;;etc...etc... (big string)
; replacement 1 output: s="aaa[]1234[]1234[]ddd[]eee[]ffff"
; replacement 2 output: s="aaa[]xbbb[]1234[]ddd[]eee[]ffff"
I have done this easily by putting the string in an array. But is it possible to do the replacements I described above by manipulating string "s" only.
With "putting the string in an array" I mean like this:
arr[0]=aaa
arr[1]=xbbb
etc...
I do not know if I am using the correct terminology when using the terms like "line" and "line number", because the string does not contain line-numbers or lines. From the help-file "A string is an array of characters.". But I still used these terms to describe the problem and the desired output.