Methods of regular expressions:
Flags | Start matching | Anchored to | Result if match | No match | re.lastIndex | |
---|---|---|---|---|---|---|
exec() | – | 0 | – | Match object | null | unchanged |
/g | re.lastIndex | – | Match object | null | index after match | |
/y | re.lastIndex | re.lastIndex | Match object | null | index after match | |
/gy | re.lastIndex | re.lastIndex | Match object | null | index after match | |
test() | (Any) | (like exec()) | (like exec()) | true | false | (like exec()) |
Methods of strings:
Flags | Start matching | Anchored to | Result if match | No match | re.lastIndex | |
---|---|---|---|---|---|---|
match() | – | 0 | – | Match object | null | unchanged |
/y | re.lastIndex | re.lastIndex | Match object | null | index after match | |
/g | After prev. match (loop) | – | Array with matches | null | 0 | |
/gy | After prev. match (loop) | After prev. match | Array with matches | null | 0 | |
search() | – | 0 | – | Index of match | -1 | unchanged |
/y | 0 | 0 | Index of match | -1 | unchanged | |
replace() | – | 0 | – | First match replaced | No repl. | unchanged |
/y | 0 | 0 | First match replaced | No repl. | unchanged | |
/g | After prev. match (loop) | – | All matches replaced | No repl. | unchanged | |
/gy | After prev. match (loop) | After prev. match | All matches replaced | No repl. | unchanged |