About multiple functions for string control
About “multiple functions for string control”
While testing my code, I realized that there are multiple functions for string control.
I would like to share them with you.
How to convert a string to upper and lower case
toUpperCase(): convert to upper case for English strings toLowerCase(): Convert to lowercase for an English string
How to determine if a string satisfies a condition based on a regular expression
Use regexObj.test(str).
Determines if the given string satisfies the regular expression, and returns true or false.
const str = "table football";
const regex = new RegExp("foo*");
// Expected output: true
How to utilize backslashes in strings
\To output the “: “ outputs a pair of quotes ": ‘ Print single quotes Print the \: Prints a \ character \r: Move the cursor to the beginning of the line \f: Move the cursor to the next page \b: move the cursor one space \t: Move the cursor by a tab \n: Move the cursor to the next line.
Example
var a = "My home is "Seoul"." : no output
var a = "My home is \"Seoul"\." : printable