I'm frsutrated by this problem and would really appreciate a hand. I may not be doing this the best way, so any suggestions are more than welcome...I want to replace certain sections of a string with other sections (substring replacements).
For example, I would like to go from something like this :
Expand|Select|Wrap|Line Numbers
- <TAG val="XXX">a hundred</TAG><TAG val="XXX">a thousand</TAG>
Expand|Select|Wrap|Line Numbers
- <TAG val="900">nine hundred</TAG><TAG val="1000">a thousand</TAG>
Expand|Select|Wrap|Line Numbers
- <TAG val="1000">nine hundred</TAG><TAG val="1000">a thousand</TAG>
To give you an idea, what I'm doing is something like this :
Expand|Select|Wrap|Line Numbers
- $text = "<TAG val="XXX">a hundred</TAG><TAG val="XXX">a thousand</TAG>";
- while ($text =~ m/val="XXX"/) {
- $text = &replace($text);
- print $text; # or whatever
- }
- sub replace {
- if ($text =~ val="XXX">(.+)</TAG> {
- $val = &convert($1);
- $text =~ s/val="XXX"/val="$val"/;
- }
- }
THANKS VERY MUCH for any comments/tips!