1
######################## Regular Expressions ##################################
2
#### WARNING: All RegExp without action specified equal $0 ~ RegExp ###########
4
/substring/ # Ok. If current string contains 'substring'
5
$6 == 'word' # Ok. If six word of current string equal to 'word'
6
$str ~ /re/ # Ok. If 'str' virable matches 're' regular expression
7
# ( 'str' contains 're' as substring )
8
$str !~ /re/ # Ok. If 'str' doesn't match 're'
9
$str ~ $re # Regexp may contain in string variable ( No need for
10
'/', but some differences occurs ( see info pages ) )
11
/^substring/ # Ok. If current string starts with 'substring'
12
/substring$/ # Ok. If current string ends with 'substring'
13
/.substr/ # Ok. If current string contains any symbol followed by 'substr'
14
# ( '.' Works as '?' )
15
/[ab]/ # OK. If current string contains a or b
17
/[0-9a-b]/ # OK. If contains number of lowercase symbols
18
/[[:class:]]/ # OK. If contains characters of some class (classes see below)
19
/[[.ab.]]/ # OK. If contains substring 'ab'
20
/[^0-9]/ # OK. If contains symbols not in [0-9]
22
/(a|b)[0-9]/ # OK for a0,a1,a2,...,b0,b1,...
23
/ab*c/ # OK for ac,abc,abbc,...,abbbbbbbc, ... ( any number of b )
24
/(ab)*c/ # OK for c,abc,ababc,...,ababababc, ...
25
/ab+c/ # OK for abc,abbc,...,abbbbbbbc, ... ( not for ac )
26
/ab?c/ # OK for 'ac' or 'abc'
27
/ab{3}c/ # OK for abbbc
28
/ab{1,3}c/ # OK for abc,abbc,abbbc
29
/ab{1,}c/ # Equal to 'ab+c'
30
RE1, RE2 # Find first ocurance of RE1, and first occurance of RE2
32
# OK. for all strings beetween RE1 & RE2
34
$0 !~ \\W\ # If current string contains only alpha numeric characters
36
################################ gawk Specific ##############################
39
\< Empty string at the start of the word ( ^ for words )
40
\> Empty string at the end of the word ( $ for words )
41
\y Can work as \< and \>
42
\B Specifies First Word or Last Word
44
########################## Possible Classes #################################
46
[:alnum:] # Alphanumeric characters.
47
[:alpha:] # Alphabetic characters.
48
[:blank:] # Space and tab characters.
49
[:cntrl:] # Control characters.
50
[:digit:] # Numeric characters.
51
[:graph:] # Characters that are printable and are also visible.
52
# (A space is printable, but not visible, while an #01' is
54
[:lower:] # Lower-case alphabetic characters.
55
[:print:] # Printable characters (characters that are not control
57
[:punct:] # Punctuation characters (characters that are not letter,
58
# digits, control characters, or space characters).
59
[:space:] # Space characters (such as space, tab, and formfeed, to name a
61
[:upper:] # Upper-case alphabetic characters.
62
[:xdigit:] # Characters that are hexadecimal digits.
63
############################################################################
65
######################## Escape Characters #################################
67
"\&" - interpreted as "&", so must been used "\\&" what interpreted as "\&"
68
Better to see info pages, it's a bit more complicated