Difference between revisions of "Regular expressions"

From MXnet
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Find everything up to a tab
 +
:<pre>[^\t]+</pre>
 +
 
Find capital letter, period, space, capital letter, period.
 
Find capital letter, period, space, capital letter, period.
 
:<pre>([A-Z]\.)[ ]([A-Z]\.)</pre>
 
:<pre>([A-Z]\.)[ ]([A-Z]\.)</pre>
Line 16: Line 19:
 
find period, capital letter at the end of a line
 
find period, capital letter at the end of a line
 
:<pre> (\.[[:upper:]])\n </pre>
 
:<pre> (\.[[:upper:]])\n </pre>
 +
 +
find lowercase characters one-at-a-time
 +
: <pre>([a-z])</pre>
  
 
<pre>
 
<pre>
 
\s\(([0-9]{4})
 
\s\(([0-9]{4})
  
 +
\s[[:upper:]]+\r
 +
 +
\L\1\n -- lowercases everything
 +
 +
\L2\1\n -- inserts 2, space, lowercase of the string
 +
 +
\L$2\1\n -- does not insert 2, lowercases string
  
 +
\U\L\1\n -- lowercases everything
  
  

Latest revision as of 18:39, 20 May 2019

Find everything up to a tab

[^\t]+

Find capital letter, period, space, capital letter, period.

([A-Z]\.)[ ]([A-Z]\.)

Kill the space by using this for the replacement field:

$1$2

Perl: find uppercase words.

 \b[[:upper:]]{2,}\b

find capital letter at the end of a line, insert period before newline

(\s[[:upper:]])\n

\1\.^p

find period, capital letter at the end of a line

 (\.[[:upper:]])\n 

find lowercase characters one-at-a-time

([a-z])
\s\(([0-9]{4})

\s[[:upper:]]+\r

\L\1\n -- lowercases everything

\L2\1\n -- inserts 2, space, lowercase of the string

\L$2\1\n -- does not insert 2, lowercases string

\U\L\1\n -- lowercases everything


Links