File: regex-example

package info (click to toggle)
regex-clojure 1.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 212 kB
  • sloc: xml: 45; makefile: 24; sh: 17
file content (17 lines) | stat: -rwxr-xr-x 444 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

set -e

snippet='(require '"'"'net.cgrand.regex)
(def datestamp-re
  (let [d {\0 \9}]
    (net.cgrand.regex/regex [d d d d :as :year] \- [d d :as :month] \- [d d :as :day])))

(net.cgrand.regex/exec datestamp-re "2007-10-23")'

output=$(clojure -cp /usr/share/java/regex.jar -e "${snippet}")

echo $output | grep ':day "23"'
echo $output | grep ':month "10"'
echo $output | grep ':year "2007"'
echo $output | grep 'nil "2007-10-23"'