53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
#!/usr
|
|
# AWK hl test
|
|
|
|
# <beginfold id='1'>BEGIN</beginfold id='1'> and <endfold id='1'>END</endfold id='1'> are also matched as patterns
|
|
BEGIN <beginfold id='2'>{</beginfold id='2'>
|
|
p = 0;
|
|
<endfold id='2'>}</endfold id='2'>
|
|
|
|
/some pattern/ <beginfold id='2'>{</beginfold id='2'>
|
|
p++;
|
|
<endfold id='2'>}</endfold id='2'>
|
|
|
|
# / inside brackets is not considered end of expression
|
|
# a loose division operator (/) is not mismatched as a pattern.
|
|
$1 =~ /[^abc/]def/ || b == 3 / 5 <beginfold id='2'>{</beginfold id='2'>
|
|
|
|
gsub ( FILENAME );
|
|
|
|
<endfold id='2'>}</endfold id='2'>
|
|
|
|
# TODO and FIXME also work in comments in Awk.
|
|
|
|
# Also backslash in patterns works.
|
|
/\/usr\/bin\/awk/ <beginfold id='2'>{</beginfold id='2'> print "This is me"; <endfold id='2'>}</endfold id='2'>
|
|
|
|
END <beginfold id='2'>{</beginfold id='2'>
|
|
print p;
|
|
<endfold id='2'>}</endfold id='2'>
|
|
|
|
function myfunc()
|
|
<beginfold id='2'>{</beginfold id='2'>
|
|
print 42
|
|
<endfold id='2'>}</endfold id='2'>
|
|
|
|
/abc/,/a[b]c/<beginfold id='2'>{</beginfold id='2'>
|
|
# parameter with a regex
|
|
if (match($0, /a/)) <beginfold id='2'>{</beginfold id='2'><endfold id='2'>}</endfold id='2'>
|
|
|
|
"x\ax\nx\ex\zx\023x\2x\xffx\xFf\xax\12x"
|
|
|
|
a =~ /[[:alpha:]]/
|
|
a =~ /[xx[:alpha:]xx]/
|
|
a =~ /[a-z[:alpha:]xx-]/
|
|
a =~ /[]a]/
|
|
a =~ /[-a]/
|
|
a =~ /[^]a]/
|
|
a =~ /[^-a]/
|
|
a =~ /[a]a\/\n/
|
|
# incomplete regex
|
|
a =~ /[xx[:alph
|
|
a = 23.2
|
|
<endfold id='2'>}</endfold id='2'>
|