Output o D) String Example x Ee : G © File | D:/TechNeo%20Publications/search.htmI RegExp Flags / Modifiers Flags are used with regular expressions that allow various options such as global search, case-insensitive search, etc. It can be use separately or together. “ml 6 oa g Performs a global match (find all matches) m Performs multiline match i Performs case-insensitive matching Character Classes ‘Square brackets surrounding a pattern of characters are called a charactet class e.g. [abc]. A character class always matches a single character out of a list of specified characters that means the expression [abc] matches only a bor c character. A negated character class is defined by placing a caret (*) symbol immediately after the opening bracket, like [abc], which matches #") character except a, b, and c, ey Sse nn ena See ene ene nnn Cnn cal s (New Syll. w.e.f academic year 19-20) (D5-16A) lal rech-neo Publication _—— CO nt Side Scripting Language (MSBTE) (Reg, Exp., Rollover & Frames) Pg. no. (5-5) » The range of characters is defined by using the hyphen (-) character inside a character class, like [0-9]. following character classes are: Description Matches any one of the characters a, b, or c. [Aabc] Matches any one character other than a, b, or c. | [az] Matches any one character from lowercase a to lowercase z. [A-Z] Matches any one character from uppercase A to uppercase Z [eZ] Matches any one character from lowercase a to uppercase Z. | [0-9] Matches a single digit between 0 and 9. r . | [a-20-9) Manes a single character between a and z or between 0 Predefined Character Classes / Metacharacters * A metacharacter is simply an alphabetical character preceded by a backslash that acts to give the combination a special meaning. ¢ It works similar like character classes and it is use shorthand character expression to represent patterns in regular expressions. Following predefined character classes are: ian oe ee Matches any single character except newline \n. \d Matches any digit character. Same as [0-9] | Matches any non-digit character. Same as [0-9] | \s Matches any whitespace character (space, tab, newline or } carriage return character). Same as [ \t\n\r] \s Matches any non-whitespace character. Same as [* \t\n\r] | \w Matches any word character (defined as a to z, A to Z,0 to 9, and the underscore). Same as [a-zA-Z_0-9] _\w Matches any non-word character. Same as [*a-zA-Z_0-9] New Syl, wef academic year 19-20) (D5-16A) ae ech-Neo PublicationsSSS =e — Client Side Scripting Language (MSBTE) (Reg. Exp., Rollover & Frames) Pg, no (64 =) Repetition Quantifiers © The quantifiers are used to specify how many times a character in regular expression should match. ‘ * — Quantifiers can be applied to the individual characters, as well as Classes of characters, and groups of characters contained by the parentheses, Following repetition quantifiers are: Expression Description pt Matches one or more occurrences of the letter p. p* Matches zero or more occurrences of the letter p. p? Matches zero or one occurrences of the letter p. p{2} Matches exactly two occurrences of the letter p. Matches at least two occurrences of the letter p, but not more than three occurrences p{2,3} p{2,} Matches two or more occurrences of the letter p. pt.3} Matches at most three occurrences of the letter p Ya 5.1.1 Language of Regular Expression e Language of regular expressions specifies the patterns used to match character combinations in strings. e In JavaScript, a Regular Expression (RegEx) is an object that describes 2 sequence of characters used for defining a search pattern. Syntax var pattern = new Reg:xp(patter, attributes); : pattern — A string that specifies the pattern of the regular expression O° another regular expression. attributes — An optional string containing any of the " attributes that specify global, case-insensitive, and multi-line respectively. i", and “" matches at ions Bal rech-Neo Publication (New Syll. wef academic year 19-20) (D5-16A)gide Senpting Language (MSBTE) (Reg. Exp., Rollover & Frames) Pg. no. (5-7) are two different ways to create a regular expression in JavaScript: sing ® regular expression literal ; regular expression consists of a pattern enclosed between slashes /. The seat regularEXP = fabo/; ere. jabc/ is a regular expression. b Using the RegExp() constructor function gecond way, tO create a regular expression by calling the RegExp() constructor function. Example const reguarExp = new RegExp(‘abc'); OR const regex = new RegExp(/~a...s8/); console.log(regex-test(‘alias')); // true In the above example, the string alias matches with the RegEx pattern /“a...s$/. Here, the test() method is used to check if the string| matches the pattem; return true if string is matched. %& 5.1.2 Finding Non Matching Characters * The character class expression [Aa-z] (non-lowercase) is use to find out non-matching characters from lowercase [a] to lowercase [z] by adding caret () symbol at the beginning of a string. We can also find out non-matching characters from uppercase and digit by using [‘A-Z] (non-uppercase) and [*0-9] (non-digit) character classes expression. ‘ample 1S Write a Program to find non-matching characters in given regular : ‘____ &xpression. ! “head >