Skip to main content
Participating Frequently
July 11, 2023
Frage

Making the numbers All Caps instead of the letters

  • July 11, 2023
  • 1 Antwort
  • 202 Ansichten

How do I make the numbers inside the textbox All Caps() instead of the letters.

 

Working code:

 

txt = thisLayer.text.sourceText;
hasNumbers = /\d/.test(txt);

if (hasNumbers) {
txt.toUpperCase();
} else {
txt;
}

 

Thanks

Dieses Thema wurde für Antworten geschlossen.

1 Antwort

Mylenium
Legend
July 11, 2023

Your code doesn't make much sense. You're not actually invoking a string substitution with .replace() anywhere. You're just testing a regular expression for true or false. Either uesregex.replace() on your numerals or funnel the captured regex filter through a JS replace. additionally you will of course need to deal with the rest of the string and slice & dice it, then re-assemble with the changed numbers.

 

Mylenium

Participating Frequently
July 11, 2023

Thanks Mylenium, Im kinda new to this so im just using what I can find online. can you teach me how to write this?

Participating Frequently
July 11, 2023

txt = thisLayer.text.sourceText;
hasNumbers = /\d/.test(txt);

if (hasNumbers) {
hasNumbers.uesregex.replace();
} else {
txt;
}