Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeConfluence
languagejavascript
my_str = "This is a string";
a = my_str.match(re/is/) // a = true
b = my_str.match(re/mouse/) // b = false

ord()

The ord() operator returns a numeric ASCII value of the first charger in the string on which it operates.  For example:

Code Block
languagejavascript
a = ('K').ord(); // a: 75

The inverse of ord() is chr().

replace()

The replace() operator takes two arguments: a regular expression and a string. The returned string is the original string with any match of the regular expression replaced by the second argument. You can use any captured values in the second, substitute string by naming them with $1, $2, and so on. The first captured value will be substituted for $1, the second for $2, and so on. For example:

...