Adding one occurrence to string.

Hai, I want to add only one occurrence of word to string like, If I have list of names in  name attribute. I want to add these names in another string only one time even though name repeats many times.  
1 answers

You could use the isMatch function to look in your list of names to see if it already exists before appending if it doesn’t. So if you are wanting to change $names and potentially append $newname to it, try something like this

if (isMatch($names, '.*\b($newname)\b.*')) then
  $names + ' ' + $newname

isMatch lets us use a regular expression, so here we look for zero or more characters before a word boundary, then the name you want to see is in your list of names, followed by another word boundary.

Hope this helps.