What is Regular Expression?
1.
A text string pattern matching mechanism. Usually applied to individual lines of text, such as from a simple text file, where the regular expression (sometimes abbreviated as RE) pattern can be used to precisely specify which lines ought to match and which shouldn't. The more complicated REs may look very confusing to people who don't know them, as they look more like a random string of letters and other characters without any obvious meaning.
Commonly they're enclosed between slashes (/like this/), because that's how they were used in many ancient
The
REs come in two forms: Basic REs and Extended REs, varying slightly in syntax and possible contructs. Perl extens the Extended REs even further and has defined the standard "Perl Compatible REs" (PCRE).
"some example string" =~ /^s*.*e+.*(?:x.* )?.*?g$/
result: 1 (because the regular expression between the // matches the string)
See