Copy link to clipboard
Copied
Another question ragarding .replace: I want to remove the line breaks before and after all "'*" characters in a layer source text:
"Text 1
*
Text 2
*
Text 3"
should turn into "Text 1*Text 2*Text 3". I've recently learned that .replace only affects the first instance, and needs to be complemented by a /g (as in "global"). However, I can't find out exactly how to make this work. This is my best attempt:
text.sourceText.replace(/\r*\r/g, "*")
but it doesn't work. What am I doing wrong here?
Try this:
text.sourceText.replace(/\r\*\r+/g, "*")
Copy link to clipboard
Copied
Try this:
text.sourceText.replace(/\r\*\r+/g, "*")
Copy link to clipboard
Copied
Thank you, it works! What is the "+" about? For me it works without it as well.
Copy link to clipboard
Copied
Look at this:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now