Skip to content

basic_matching

Bruce Armstrong edited this page Oct 27, 2016 · 7 revisions

Basic Matching

This is mostly to get you familiar with the ui of the website, we'll get on to the good stuff really soon, don't worry. [delete]: # (https://regex101.com/delete/V63qKvpznAtXU62q82pM3VBg)

Quick basic reference

Thing Meaning
. Match any character (except newline)
| Alternation, like or. `a
|Escape something (\. will match an actual period instead of its normal meaning)
\t tab (HT, TAB)
\n newline (LF, NL)
\r return (CR)
\f form feed (FF)
\a alarm (bell) (BEL)
\e escape (think troff) (ESC)
\cK control char (example: VT)
\x{}, \x00 character whose ordinal is the given hexadecimal number
\N{name} named Unicode character or character sequence
\N{U+263D} Unicode character (example: FIRST QUARTER MOON)
\o{}, \000 character whose ordinal is the given octal number

Given the from wikipedia (regex101 with text already inserted), please:

  • Find 'regular'
  • Find 'regular' or 'regex' using the alternation operator '|'
  • To find 'cat' or 'dog', the expression would be /cat|dog/
  • Try Debuggex site for a graphical representation of your expression

Exercise text

In theoretical computer science and formal language theory, a regular expression (sometimes called a rational expression)[1][2] is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. "find and replace"-like operations. The concept arose in the 1950s, when the American mathematician Stephen Kleene formalized the description of a regular language, and came into common use with the Unix text processing utilities ed, an editor, and grep, a filter.

In modern usage, "regular expressions" are often distinguished from the derived, but fundamentally distinct concepts of regex( pronunciation: /ˈrɛɡɛks/; hard g as in gaggle; rhymes with FedEx) or regexp, which no longer describe a regular language. See below for details.

Regexes are so useful in computing that the various systems to specify regexes have evolved to provide both a basic and extended standard for the grammar and syntax; modern regexes heavily augment the standard. Regex processors are found in several search engines, search and replace dialogs of several word processors and text editors, and in the command lines of text processing utilities, such as sed and AWK.

Many programming languages provide regex capabilities, some built-in (for example Perl, JavaScript, Ruby, AWK, and Tcl) and others via a standard library (for example .NET languages, Java, Python, POSIX C, and C++ since C++11). Most other languages offer regexes via a library.```

Clone this wiki locally