For Programmers: Free Programming Magazines  


Home > Archive > AWK > February 2008 > [announcement] runawk-0.11.0 has been released









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [announcement] runawk-0.11.0 has been released
Aleksey Cheusov

2008-02-09, 6:58 pm


runawk-0.11.0 has been released
Source code is available from http://sourceforge.net/projects/runawk

Feedback is welcome

NEWS:

New modules

tokenre.awk:

By default AWK splits input strings into tokens according to regular
expression that defines "space" between tokens using special
variable FS. In many situations it is more useful to define regular
expressions for tokens themselves. This is what this module does.

tokenre(STRING, REGEXP)
`tokenre' extracts substrings from STRING
according to REGEXP from the left to the right and assigns $1, $2
etc. and NF variable.

tokenre0(REGEXP)
Does the the same as `tokenre' but splits $0 instead

TRE - variable. If it is set to not empty string, splitting is
made by default for all input strings.

For example:
tokenre("print \"Hello world!\"", "\"([^\"]|\\\")*\"|[[:alnum:]_]+")
| NF == 2
| $1 == print
| $2 == "Hello world!"

str2regexp.awk

str2regex(STRING)
returns a regular expression that matches given STRING

For example:
print str2regexp("all special symbols: ^$(){}[].*+?|\\")
-| all special symbols: [^][$][(][)][{][}][[]\][.][*][+][?][|]\\

multisub.awk

multisub(STRING, SUBST_REPLS)
`multisub' is a substitution function. It searches for
a list of substrings, specified in SUBST_REPL
in a left-most longest order and (if found) replaces
found fragments with appropriate replacement.
SUBST_REPL format: "SUBSTRING1:REPLACEMENT1 SUBSTRING2:REPLACEMENT2...".
Three spaces separate substring:replacement pairs from each other.

For example:
print multisub("ABBABBBBBBAAB", "ABB:c BBA:d AB:e")
|- ccBBde

--
Best regards, Aleksey Cheusov.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com