[racket] Use regexps or something else?

From: Rodolfo Carvalho (rhcarvalho at gmail.com)
Date: Sat Jun 4 00:17:07 EDT 2011

On Sat, Jun 4, 2011 at 01:02, Rodolfo Carvalho <rhcarvalho at gmail.com> wrote:

> [...]
>> > I couldn't find a way to match groups.
>> > I'd like to have something like this:
>> >
>> > (define t "
>> > 23                12
>> > 15                45
>> > 32                27")
>> > (regexp-match-groups* #px"(\\d+)\\s+(\\d+)" t)
>> >
>> > => '(("23" "12") ("15" "45") ("32" "27"))
>> >
>> > Does such a thing exist?
>>
>> No.  You can do this:
>>
>>  (regexp-match* #px"(\\d+)\\s+(\\d+)" t)
>>
>> where regexp-match gives you all of the complete matches, but not the
>> matched groups.  It could be added, but it seems like a questionable
>> extension.
>>
>>


If there would be groups, we could deliberately "ignore" parts of our input
-- parts that are important to match a valid sentence but not important for
output.

Imagine an scenario that instead of 2 (as above) we had 20 columns of a
table, and we wanted to return a table of the squares of the values for all
columns, except for columns 12 and 15 (of course we could parse them out and
ignore then when processing/returning, but you get the idea...)

[]'s

Rodolfo Carvalho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110604/a5dd9445/attachment.html>

Posted on the users mailing list.