Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
[newLISP][PCRE]Perl互換正規表現のサンプル
#!/usr/bin/env newlisp
# change all "foo.bar.com" style names in the input stream
# into "foo.bar.com [204.148.40.9]" (or whatever) instead
# Original Source (perl) - http://docstore.mik.ua/orelly/perl4/cook/ch06_05.htm
# Usage: newlisp hostcvt.lsp < /etc/hosts
(define (echo (in 0) (out 1))
(let (buf)
(while (read in buf 0x400)
(write out buf))
(if (string? out) out true)))
;; Read stdin into string
(setq TEXT (echo 0 ""))
(replace
{ # substitute this:
( # capture the hostname in $1
(?: # these parens for grouping only
(?! [-_] ) # next mustn't be underbar or dash
[\w-] + # one or more alphanums or dashes
\. # and the domain dot
) + # now repeat that whole thing a bunch of times
(?= [a-z] ) # next must be a letter
[\w-] + # one or more alphanums or dashes
) # end of $1 capture
}
TEXT
(format "%s [%s]" $1 (or (net-lookup $1) "???"))
(| 1 8) ; (i)PCRE_CASELESS, (x)PCRE_EXTENDED
)
(print TEXT)
(exit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.