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?
Thanks!!
Target specific words in text
Moderator: Paul Tuersley
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
https://jsbin.com/kesuninehu/edit?js,console
You could then maybe use that with indexOf to find the indexes.
Hopefully that might help you figure something out
Rune
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
Code: Select all
text.indexOf("word")
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
Rune