[racket] Destructuring-bind for Regex
>> how () in regular expressions work
Thanks much.
On Fri, Jan 4, 2013 at 3:44 PM, Sam Tobin-Hochstadt wrote:
> On Fri, Jan 4, 2013 at 3:37 PM, Galler <lzgaller at optonline.net> wrote:
>> Could you possibly briefly elaborate on how the parentheses in the
>> regular
>> expression make the destructuring work?
>
> The () in the pattern work exactly like they do in `regexp-match`.
>
>> (regexp-match #px"([\\D]*)([\\d]+\\.[\\d]+)([\\D]*)" "This is a 40.2
>> Song about Japan")
> '("This is a 40.2 Song about Japan" "This is a " "40.2" " Song about
> Japan")
>
> Scroll down in these docs:
>
> http://docs.racket-lang.org/reference/regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp-match%29%29
> to where it says "additional [byte] strings" to see a full description
> of how () in regular expressions work.
>
> Sam