Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hello,
I try to use the ACL function "gsub" to replace the string "and" by the character ampersand (&). But the replacement fails. Do you have a solution ?
David
Solved! Go to Solution.
Try this: gsub("and", "\\&", "Mk1 and Mk9")
We use similar substitutions frequently in our customizations for Arbortext Editor.
Rick
I haven't tried but I suspect you need to replace "and" with "&" or "&" because the ampersand character by itself is not permissible in XML. It is a special symbol for the XML parser.
Hello,
Thanks for your response.
I try your solution but it doesn't work.
The result of the command:
sub("and", "&", "Mk1 and Mk9")
is "Mk1 andamp; Mk9"
In the documentation of the "sub" function: we can read:
If the replace string contains a “&” or “\0”, then it is replaced with the substring that matched regexpr.
David
Yes, sorry I hadn't tried. Does escaping the ampersand help?
sub("and", "\&", "Mk1 and Mk9")
BTW that looks like S1000D bike data 🙂
Thank you again for your help
I have tried with the escaping character, but the result is always incorrect.
Thank you again for your help
I have tried with the escaping character, but the result is always incorrect.
Try this: gsub("and", "\\&", "Mk1 and Mk9")
We use similar substitutions frequently in our customizations for Arbortext Editor.
Rick
Hello Rick,
Thank for your solution.
It works.