homerUK
03-17-2004, 04:15 PM
Hey,
I have a string of text which might be something like
Dear {firstname},
Welcome to {clubName}
- The text above is loaded in to an iFrame so the user can edit the text.... I have an onload event attached to the iFrame which loads the text in to a variable...
.. I then need to loop through a list of fields in an array. The script needs to read the variable and search for a pattern of something like
{ + field array name + }
if it finds one, then it should highlight or make bold or something. I just dont know how to write the regexp part to do it.
here's what I have which doenst work...
function highlightMarkers()
{
var documentText = iView.document.body.innerHTML;
for (x=0;x<fields.length;x++)
{
//compare each field in the array to the document text.
regexp = "{" + fields[x] + "}";
if (documentText.search(regexp) > 0)
{
//we have found a word which is marker
//apply the formatting.
}
}
return false;
}
how do I use the regexp to search for any word which has { word } ??
thanks for any help! :thumbsup:
I have a string of text which might be something like
Dear {firstname},
Welcome to {clubName}
- The text above is loaded in to an iFrame so the user can edit the text.... I have an onload event attached to the iFrame which loads the text in to a variable...
.. I then need to loop through a list of fields in an array. The script needs to read the variable and search for a pattern of something like
{ + field array name + }
if it finds one, then it should highlight or make bold or something. I just dont know how to write the regexp part to do it.
here's what I have which doenst work...
function highlightMarkers()
{
var documentText = iView.document.body.innerHTML;
for (x=0;x<fields.length;x++)
{
//compare each field in the array to the document text.
regexp = "{" + fields[x] + "}";
if (documentText.search(regexp) > 0)
{
//we have found a word which is marker
//apply the formatting.
}
}
return false;
}
how do I use the regexp to search for any word which has { word } ??
thanks for any help! :thumbsup: