// .. (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