# AS2:: Textformatting::

**URL:** <https://forum.kirupa.com/t/as2-textformatting/237224>\
**Category:** flash\
**Created:** [August 28, 2007, 11:03am UTC](https://forum.kirupa.com/t/as2-textformatting/237224 "2007-08-28T11:03:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lilleypants](https://avatars.discourse-cdn.com/v4/letter/l/f17d59/32.png) [@lilleypants](https://forum.kirupa.com/u/lilleypants)\
**Post date:** [August 28, 2007, 11:03am UTC](https://forum.kirupa.com/t/as2-textformatting/237224/1 "2007-08-28T11:03:43Z")

</div>

Hi,

I’ve been developing a piece of code that looks for keywords inbetween tags, and then stores these into an array (hlword) I am now trying to get it so that when it finds these words, it makes the word bold and changes the colour.

[FONT=Courier New]var origString:String = content\_txt.text;[/FONT]  
[FONT=Courier New] var inChar1 = “–!”; //wraps around hyperlink  
var inChar2 = “!–”;

var hlword = new Array(); //define variables  
var tempword = “”;  
var outString = “”;

var newString = origString.split(inChar1); //split the string

//trace(newString);  
for(i = 0; i \< newString.length -1; i++) // get the hyperlink words  
{  
tempword = newString[i+1].split(inChar2);  
hlword.push(tempword[0]);  
trace(hlword);[/FONT]  
[FONT=Courier New] }

[COLOR=darkorange]for(chr in hlword){[/COLOR][/FONT]  
[FONT=Courier New][COLOR=darkorange]var format:TextFormat = new TextFormat();  
format.color = 0x8DC0E4;  
format.bold = true;  
hlword.text.setTextFormat(format);  
}[/COLOR][/FONT]

The code in orange is what I have been working on in an attempt for it to change the Textformat - Is this going a long the right lines?

Any advice would be great thanks!
