<div dir="ltr"><div><div>No, regexp-match is designed to return first the entire match followed by the matched parenthesized expressions.<br></div>You can always write a wrapper that returns the parenthesized expressions if you want:<br>
<br>#lang racket<br><br>(define (regexp-match-sub-matches rx str)<br> (cdr (or (regexp-match rx str) '(a . #f))))<br><br>(regexp-match-sub-matches #rx"\"(.*)" "a\"b") ; => '("b")<br>
<br><br></div>Laurent<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 10, 2013 at 5:27 PM, Don Green <span dir="ltr"><<a href="mailto:infodeveloperdon@gmail.com" target="_blank">infodeveloperdon@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Regexp question:<br></div>Is there a way using regexp only to return a list with a single element?<br>
<div><div>I could use a Racket list function such as caar to return the second element but I am wondering if there is a way to do this using regexp only.<br>
</div><div><br>For example this regexp-match function generates the "b" that I want but it is the second element in the list. It would be ideal, from my perspective, if that was all it generated. Is there a way to write the regexp-match expression so that '("b") is output?<br>
<br>I get this:<br>(regexp-match #rx"\"(.*)" "a\"b") ; => '("\"b" "b")<br><br></div><div>I'd prefer:<br></div><div>(regexp... "a\"b" ) ; => '("b")<br>
<br></div><div>Thanks.<span class="HOEnZb"><font color="#888888"><br>Don Green<br>
</font></span></div></div></div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>