Copy link to clipboard
Copied
I am trying to search for the occurrence of a "(" within a text string - unfortunately my code is reported as incorrect.
I extract the text correctly but cannot create the search statement correctly:
var mylistpgftext = pgf.GetText (Constants.FTI_String)
for (var i=0; i < mylistpgftext.length; i++)
{
var mylistitem = mylistpgftext.sdata
var mybracketpos = mylistitem.search(/(/i) --------------error line-----------------
if (mybracketpos != -1)
{
alert(mylistitem)
}
}
Hi Bob, I did not test this, but I think the problem is an unescaped character in your regular expression. Try this.
var mybracketpos = mylistitem.search(/\(/i);
Notice the backslash before the open parens that you are searching for.
-Rick
Copy link to clipboard
Copied
Hi Bob, I did not test this, but I think the problem is an unescaped character in your regular expression. Try this.
var mybracketpos = mylistitem.search(/\(/i);
Notice the backslash before the open parens that you are searching for.
-Rick
Copy link to clipboard
Copied
If a regular expression isn't required, I would think that indexOf would be easier:
var mybracketpos = mylistitem.indexOf("(");
Russ
Copy link to clipboard
Copied
Hi Russ and Rick,
Finger trouble with Rick reply.
They both work perfectly!!
Many thanks to you both.
Bob
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more