JavaScript RegExp . meta characters

Definition and usage

. Meta characters match any character, except for newline characters or other line termination characters.

instance

Global search "h.t":

let text = "That's hot!";
let pattern = /h.t/g;

Try it yourself

syntax

new RegExp("regexp.")

or abbreviated as:

/regexp./

Syntax with modifiers

new RegExp("regexp.\(g\)

or abbreviated as:

/regexp./g

browser support

/./ is ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
supported supported supported supported supported supported

Regular expression search methods

In JavaScript, regular expression text search can be completed using different methods.

usagePattern (pattern)As regular expressions, these are the most commonly used methods:

example description
text.match(pattern) string method match()
text.search(pattern) string method search()
pattern.exec(text) RexExp method exec()
pattern.test(text) RexExp method test()