Page 1 of 1
Target specific words in text
Posted: February 7th, 2017, 6:16 am
i want to be able to type in text, and have specific words (or words surrounded by specific sumbols, like for example this: [the word]) targetted with a script, so the font automatically gets changed, or he color changes, etc.
Do you guys or girls think this is possible, and if so, how should I handle this?
Re: Target specific words in text
Posted: February 7th, 2017, 7:00 am
You can only set one style for a text layer via script, if you need multiple styles you need to create more text layers and find a way to place them.
If you only need to change the color, or other properties that is not the font, you can maybe look into using an expression selector on the text layer.
To find a word you can use
to find where the word is.
To find words surrounded by symbols you might have to use a regular expression
Code: Select all
var text = "Lorem [ipsum] dolor [sit] amet"
var match = text.match( /(\[.*?\])/g );
console.log( match ); // Logs ["[ipsum]", "[sit]"]
You could then maybe use that with indexOf to find the indexes.
Hopefully that might help you figure something out