...
Code Block | ||||
---|---|---|---|---|
| ||||
foo = "I like cheese";
my_str = "This is a string";
a = my_str.extract(re/(is)/) // a = ["is"]
b = my_str.extract(re/(s.+).*(.ing)/) // b = ["s is a st","ring"]
c = my_str.extract(re/(boot)/) // c = []
d = foo.extract(re/like (\w+)/) // d = ["cheese"]
e = foo.extract(re/(e)/g) // e = ["e","e","e","e"] |
Note that if the regular expression does not contain at least one capture group, the resulting array will be empty.
...
Code Block | ||||
---|---|---|---|---|
| ||||
my_str = "This is a string";
my_str.substr(5); // returns "is a string"
my_str.substr(5, 4); // returns "is a"
my_str.substr(5, -5); // returns "is a s"
my_str.substr(25); // returns null |
...