hello, Iām trying to understand how to use m/re
to match something, but I always get nil, example:
(m/find "csa sa R$ 231,52 casa"
(m/re #"\d{3},\d{2}" ?0)
?0)
is this intended to be used to match like this?On my phone. But from the doc string re uses re-matches. Which matches the whole string. So my guess is you need a pattern that matches the entire string, not just part of it.
humm, is there a way to use with re-find
? in my case I have these long strings, and just wanna match a small portion of it, and extract it in the process
Iām getting around using (m/pred #(re-find ...))
, but that forces me to run the regex twice (to extract the content later), and look ugly, the syntax on m/re
is just perfect, but having problems to match the small string in a long text
Would changing you regex to this and grabbing group 1 not work? .**(\d{3},\d{2}).**
Or are you looking for multiple matches?
If so, I can look at this later when not on my phone.
no, a single match, I got it work with #"(?s).*(\d+,\d{2}).*"
š
humm, kind of
it matches, but now it matches the last occurence, while I need the first
I guess having one to match all would be nice
Just change the first to non-greedy star .*?
sorry, was my bad, its matching the right thing š
and yes, non-greedy should solve if that was the case
all working nice now, thanks @jimmy!
No problem :). Glad it is working.