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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -