Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript regex test match

// .test(string) is a method of the RegExp class
//   returns a boolean value
// .match(regexp) is a method of the String class
//   if global flag (g) is included, returns an array of matched instances

const str = "A text string!";
const reg = /t/g; // matches all lower case "t"s

reg.test(str); // returns true
str.match(reg); // returns ['t', 't', 't']
 
PREVIOUS NEXT
Tagged: #javascript #regex #test #match
ADD COMMENT
Topic
Name
1+7 =