# Be clever with strings

**URL:** <https://forum.kirupa.com/t/be-clever-with-strings/290013>\
**Category:** Uncategorized\
**Created:** [June 8, 2009, 5:03pm UTC](https://forum.kirupa.com/t/be-clever-with-strings/290013 "2009-06-08T17:03:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulscanlon\_99](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@paulscanlon\_99](https://forum.kirupa.com/u/paulscanlon_99)\
**Post date:** [June 8, 2009, 5:03pm UTC](https://forum.kirupa.com/t/be-clever-with-strings/290013/1 "2009-06-08T17:03:10Z")

</div>

Hi all i have a problem that i have no idea how to solve. I’ll start with what i’d like to be able to do.

i have a dynamic text feild which is being populater with text.

disText.text = “I may start “utopian island” soon. Then we can recline while the robots and the  
animals do our bidding. Within reason. No monkeys in bras. &&about 1 hour ago from web”;

i can format this text like so:

myformat = new TextFormat();  
myformat.color = 0x004487;  
myformat.size = 16;  
myformat.align = “center”;  
myformat.font = “Arial”;

\_root.disText.setTextFormat(myformat);

okay so that is all good.

Now i need to search the string and find the &&, any text after this point will need to be formatted in a different way.

i have done a search and replace

function searchReplace(block:String, find:String, replace:String):String {  
return block.split(find).join(replace);  
}

disText.text = searchReplace(\_root.disText.text, “&”, “”)

so that the special characters are replaced with nothing but i cant find a way of findig out where in the string the special characters were and how to modify the text that is after the special characters i.e the about 1 hour ago

is there a better way of approaching this or is it even possible?
