JavaScript Help Question what are and called when referrin

JavaScript Help:

Question: what are ^ and $ called when referring to regular expressions?

Examples:

** Question: What is the + doing in the first example?

**Question: How does that change if the string is allowed to be empty?

Solution

^ $ are in specify the begining and ending of string.

^ --> begining

$ --> ending

Question 2:

console.log( /^\\S+$/.test(s) )

/^\\S+$/ in that \\S Find a non-whitespace character and + represent matching string that contains at least one \\S

Question 3:

How does that change if the string is allowed to be empty?

in regular expersion

. represents ans single character so

/^.*$/ here a single character can repeat zero or more occurrences so it excepts empty string

JavaScript Help: Question: what are ^ and $ called when referring to regular expressions? Examples: ** Question: What is the + doing in the first example? **Que

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site