javascript - What does this `/^.*$/` regex match? -
i'm maintaining old code when reached headscratcher. confused regex pattern: /^.*$/
(as supplied argument in textfieldvalidation(this,'true',/^.*$/,'',''
).
i interpret regex as:
- /^=open pattern
- .=match single character of value (except eol)
- *=match 0 or more times
- $=match end of line
- /=close pattern
so…i think pattern matches everything, means function nothing waste processing cycles. correct?
it matches single line of text.
it fail match multiline string, because ^
matches begining of input, , $
matches end of input. if there new line (\n
) or caret return (\r
) symbols in between - fails.
for example, 'foo'.match(/^.*$/)
returns foo
.
but 'foo\nfoo'.match(/^.*$/)
returns null
.
Comments
Post a Comment