Now that we understand a bit about variables and datatypes, let's see what can be done with strings.
There are over 30 'methods' or things that can be done with strings, but here we will discuss some of the most common and useful ones. You are encouraged to dig deeper if you need.
Many times we need or want to know how long a string is - how many characters does it contain. This may not be as straight-forward as you think.
Typically we simply use the length method ...
let myStr="How long is this string?";
Sprint('<p>'+myStr+'<br/>');
Sprint('<p>myStr is '+myStr.length+ ' characters long.</p>');
Well, that checks out OK.
Now consider Unicode characters. Some of them may consist of 2 or more 'characters' or 'glyphs' or 'grapheme clusters', depending on the language being used.
For example, how long is the string Amon Düül?
Well, I count 9 characters, but wait a minute...
And what about emoticons?
Well, that throws a wrench into things.
Trying a new method:
Sprint(myStr.match(/./gu).length);
This method shows the 'user-perceived' length returned, which uses the Unicode regex flags.
You may never need to implement these conniptions with 'length', but in case you do, be aware of them.
Strings - Escape