regex how many times 1 is code example

Example 1: regex quantifiers

/* matching using quantifiers */
regex= /X./; // matches any character
regex= /X*/; // Matches zero or several repetitions of letter X, is short for {0,}
regex= /X+-/; // matches one or more repetitions of letter X, is short for {1,}
regex= /X?/; // finds no or exactly one letter X, is short for is short for {0,1}.
regex= // d{3}; // matches three digits. {} describes the order of the preceding liberal
regex= // d{1,4} ; // means d must occur at least once and at a maximum of four
A quantifies helps developers to define how often an element occurs.

Example 2: javascript regex zero or more occurrence

// /x*/ - Regular Expression zero or more occurrence
console.log(/'\d*'/.test("'123'"));// true
console.log(/'\d*'/.test("''"));// true