/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/languages/awk/awk.regexp

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
######################## Regular Expressions ##################################
 
2
#### WARNING: All RegExp without action specified equal $0 ~ RegExp ###########
 
3
 
 
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
 
16
/[0-9]/         # Works to
 
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]
 
21
/^P|[0-9]/      # OR.
 
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
 
31
                # ( first after RE1 )
 
32
                # OK. for all strings beetween RE1 & RE2
 
33
 
 
34
$0 !~ \\W\      # If current string contains only alpha numeric characters
 
35
 
 
36
################################ gawk Specific ##############################
 
37
\w              [[:alnum:]_]
 
38
\W              [^[:alnum:]_]
 
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
 
43
 
 
44
########################## Possible Classes #################################
 
45
 
 
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 
 
53
                # both.)
 
54
[:lower:]       # Lower-case alphabetic characters.
 
55
[:print:]       # Printable characters (characters that are not control
 
56
                # characters.)
 
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
 
60
                # few).
 
61
[:upper:]       # Upper-case alphabetic characters.
 
62
[:xdigit:]      # Characters that are hexadecimal digits.
 
63
############################################################################
 
64
 
 
65
######################## Escape Characters #################################
 
66
WARNING:
 
67
    "\&" - interpreted as "&", so must been used "\\&" what interpreted as "\&"
 
68
    Better to see info pages, it's a bit more complicated