Regular Expressions

Automation theory term project

What is Regex

RegExp Object
A regular expression is an object that describes a pattern of characters.
Regular expressions are used to perform pattern-matching and "search-and-replace" functions on text.
Creating a regular expression:

var re = /ab+c/;
var re = new RegExp('ab+c');  

RegEx Methods

Method Description
exec A RegExp method that executes a search for a match in a string. It returns an array of information or null on a mismatch.
test A RegExp method that tests for a match in a string. It returns true or false.
match A String method that executes a search for a match in a string. It returns an array of information or null on a mismatch.
matchAll matchAll A String method that returns an iterator containing all of the matches, including capturing groups.
search A String method that tests for a match in a string. It returns the index of the match, or -1 if the search fails.
replace A String method that executes a search for a match in a string, and replaces the matched substring with a replacement substring.
split A String method that uses a regular expression or a fixed string to break a string into an array of substrings.

RegEx Rules

Description
. matches any character except line breaks. Equivalent to [^\n\r].
\w matches any word character (alphanumeric & underscore).
\d matches any digit character (0-9). Equivalent to [0-9].
\s matches any whitespace character (spaces, tabs, line breaks).
[ABC] matches any character in the set.
[^ABC] matches any character is not in the set.
[A-Z] matches a character having a character code between the two specified characters inclusive.
[A-Z] matches a character having a character code between the two specified characters inclusive.
+ matches 1 or more of the preceding token.
* matches 0 or more of the preceding token.
? matches 0 or 1 of the preceding token, effectively making it optional.
| acts like a boolean OR.
[A-Z] matches a character having a character code between the two specified characters inclusive.

Test pattern

Pattern Text


                    

Find pattern

Your pattern should match the highlighted words in the text section

Pattern

Text

Find words

Highlight word which matches given pattern and press add

Pattern
Text