an example of how to parse a string and globally replace occurrences of strings matching a pattern?
I come from a Perl background and what I want to be able to do with an iphone app is to parse Ansi color codes from a text string to create a string with the colors specified via html font tags.
Here is a quick Perl example which substitutes the yellow escape code ( \e[31m ) for the yellow font tag inside the string $string
Code:
$yellow_start = "<font color='yellow'>"; #line1
$yellow_end = "</font>"; #line2
$string = "\e[31mYellow\e[0m"; #line3
$string =~ s/\e\[31m(Yellow)\e\[0m/$yellow_start$1$yellow_end/g; #line4
I can do that easily enough in Perl but I am clueless about how to go about the string substitution in ObjC.
Can anybody provide me a quick example for the above? I would be most appreciative!
Thank you,
Andy