Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting arguments out of regexp

Tags:

regex

clojure

I want it to return 450 in some way, the $1 is just a silly variable name. It's like the reverse of format. What is the clojure regex magic for achieving this?

(re-something #"$1\sUSD" "450 USD")
like image 886
claj Avatar asked Jan 25 '26 07:01

claj


1 Answers

user=> (re-find #"(\d\d\d) (USD)" "450 USD")
["450 USD" "450" "USD"]
user=> (nth *1 1)
"450"
like image 106
kotarak Avatar answered Jan 26 '26 21:01

kotarak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!