examples/demo_tokenre
raw| 1 | #!/usr/bin/env runawk |
| 2 | |
| 3 | #use "tokenre.awk" |
| 4 | |
| 5 | # This demo splits input line into tokens according to regexp that |
| 6 | # defines a token, not <space> between tokens. |
| 7 | # |
| 8 | # Suported tokens: |
| 9 | # - sequence of non-space and not " characters |
| 10 | # - "la-la-la even spaces here " |
| 11 | |
| 12 | # Input files for this demo: examples/demo_tokenre.in* |
| 13 | |
| 14 | BEGIN { |
| 15 | TRE="\"[^\"]*\"|[^\"[:space:]]+" |
| 16 | } |
| 17 | |
| 18 | { |
| 19 | print "NF=" NF |
| 20 | for (i=1; i <= NF; ++i){ |
| 21 | printf "$%d=%s\n", i, $i |
| 22 | } |
| 23 | } |