GAL5t

    - Tell me .. What is it that you don't forgive me?
    - Insincerity.

    Puppeteers (Russia, 2013) 6:06 e2

Regular expressions
-------------------

or what should i do if the number of rules exceeds the number of times i'll use it?

Choose:

  1. Ignore. I don't use it at all (because i don't know how to use it).

  2. Cache. I found some formulas. They help me to solve everyday tasks. (Why do i write this, it is obvious).

  3. history | tail. Interested only in PCRE (Java flavour) -- doomed to be a "write only" kind of person.

  4. history | head. I am a fan of thermodynamics. My priority table is:
    high: understand
          feel (sense)
          use
          ignore
    low:  destroy

Partial cache, Examples, Accumulator
------------------------------------

      You can call me anything you want.

      Batman Forever, 1995, 1:09:15

..
Психология бессознательного. Зигмунд Фрейд
vi Freud.txt
1,$s/^<p class=MsoNormal>//
..
(or %s, what means the whole file)
..
2016.10.20
in a rows from file /etc/apt/sources.list replace all like
  deb http://us.archive.ubuntu.com/ubuntu/ yakkety multiverse
with
  deb http://ee.archive.ubuntu.com/ubuntu/ yakkety multiverse

/usr/bin/vi
  :s1,$/\/\/us/\/\/ee/
..
2016.10.22
$ # Row equals paragraph.
$ Require: paragraphs have to be separated with empty line.
$ cat "ENT 251 Main Course.txt" | tr '\n' '@' | \
  sed 's/\([^@]\)@\([^@]\)/\1@@\2/g' | \
  tr '@' '\n' > EN2
$ # Translate EN2 with translate.google.com into EE2
$ paste -d '\n' EN2 EE2 > ENEE

Further Readings
----------------

1. RegExr: Learn, Build, & Test RegEx

   http://regexr.com/

2. What do lazy and greedy mean in the context of regular expressions?

   http://stackoverflow.com/questions/2301285
     /what-do-lazy-and-greedy-mean-in-the-context-of-regular-expressions

3. Ryans Tutorials. Regular Expressions Tutorial.

   http://ryanstutorials.net/regular-expressions-tutorial/

4. Regular Expressions Tutorial

   http://www.regular-expressions.info/tutorial.html

5. Theory Of Automata, by Kumar. Tata McGraw-Hill Education, 2010, ISBN 0070702047, 9780070702042. 421 pages

Annex A. Regular Expressions
----------------------------

In the 1940s, Warren McCulloch and Walter Pitts modelled neurons as
finite automata to describe the nervous system. In 1956, Steve Kleene
invented a mathematical abstraction called regular sets to describe
these models.

A regular expression is notation for specifying a set of strings.
Since the set might contain infinitely many members, we can't simply
enumerate them.

There are four operations for creating regular expressions

  1. Kleene closure (replication)     *
  2. Alternation                      |
  3. Concatenation                    none
  4. Grouping                         ()

The table below illustrates them by example.

  Operation          Regular Expression   Yes     No
  ..................................................................
  Replication        ab*a                 aa      ab
  (Kleene closure)                        aba     ababa
                                          abba

  Logical OR         aa | baab            aa      every other string
  (Alternation)                           baab

  Concatenation      aabaab               aabaab  every other string

  Grouping           a(a|b)aab            aaaab   every other string
                                          abaab

The * operator has the highest precedence,then |, then concatenation.
If we want to specify the set of strings a, aba, ababa, abababa, and
so forth, we must write (ab)*a to indicate that the ab pattern must
be replicated together.

           Robert Sedgewick, Kevin Wayne, Princeton University, 2004
