That weird thing that you have to look up on stackoverflow once a year, but it's really useful when you do
Rules for the structure of the language, and how that translates to MEANING
Rules for more nuanced differentiation in meaning:
active vs passive
declarative vs imperative
Grammar is the difference between "Dog bites man" and "Man bites dog."
subject verb object
When you come to donuts, have a donut.
Some rules that apply to this sentence:
Jan walks.
Jan walks the dog.
IC = S, V, *O
Many spoken languages are not regular, because humans.
Sets of rules (grammars) which defined what keywords, expressions, characters can appear in what order, and what the meaning is of those things.
An expression is anything that can be on the left of an equals sign.
const a = b + 3
expression
Exp =:: Exp
Exp =:: Exp + Exp
Exp =:: Exp - Exp
Exp =:: (Exp)
Exp =:: Exp && Exp
Exp =:: Exp || Exp
Exp =:: ! Exp
Any computer program can be modeled as a "state machine", shown as a graph with edges and nodes
State Machine Example
ab
a*
a|b
abc+
an 'a', followed by a 'b', followed by one or more 'c's
/Hello World/
/Hello World/
match exactly "Hello World" case insensitive
Match exactly "Hello" over multiple lines
ab an 'a' followed by a 'b' a|b an 'a' or a 'b' a* any number of 'a's (including 0) a+ at least one 'a'
a? an optional single 'a'
\? an escaped '?'
. any character [a-z] any character in the range of a->z [A-Z] " " capital A->Z [0-9] " " 0->9
\d any single-digit
\w any single "word" character (alpha numeric)
^ Beginning of a string or line \b Word boundary () Group, Capture Group $ End of a string or line
Beginning of word
Group of 1 digit & optional 2nd digit with a slash
Occurs exactly twice
4 digits
Beginning of a word
A group of 1+ characters, digits, periods or plus signs
The string
"@ldschurch."
The string "org" or "net"
^(?:(?:[\w`~!#$%^&*\-=+;:{}'|,?\/]+(?:(?:\.(?:"(?:\\?[\w`~!#$%^&*\-=+;:{}'|,?\/\.()<>\[\] @]|\\"|\\\\)*"|[\w`~!#$%^&*\-=+;:{}'|,?\/]+))*\.[\w`~!#$%^&*\-=+;:{}'|,?\/]+)?)|(?:"(?:\\?[\w`~!#$%^&*\-=+;:{}'|,?\/\.()<>\[\] @]|\\"|\\\\)+"))@(?:[a-zA-Z\d\-]+(?:\.[a-zA-Z\d\-]+)*|\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])$
A "$" and a "{"
1 or more "word" characters
A single "}"
Regular expressions in javascript are primitive data types.
You can save them to variables or call their methods directly
const exp = /Hello World/;
exp.test("Hello World"); //true
/Goodbye World/.test('Hello World'); //false
RegEx.test(string) //boolean
RegEx.exec(string) //data
const isFound = /Hello World/.test("Hello World");
//true
const foundData = /Hello/.exec("Hello World");
//Array
// "Hello"
// index: 0
// input: "Hello World"
String.match(RegEx) //array
String.search(RegEx) //index
String.replace(RegEx) //string
String.split(RegEx) //array
"Hello World".match(/World/); //Data
"Hello World".search(/World/); //6
"Hello World".replace(/World/, "Everybody!"); //Hello Everybody!
"Hello World".split(/\s/); //["Hello", "World"]
/end|beginning/igm