<div dir="ltr"><div><div>Chris,<br><br>The regexp-match* function has a rather complex input/output specification, because it is doing a lot of things at once.  If you only want the first match of a regular expression, you might want to consider regexp-match instead (no *); its specification is slightly simpler, though still a little complex.<br>

<br>The car function, on the other hand, is very straightforward.  Given a list, it extracts and returns the first element of that list.  The name &quot;car&quot; is rather anachronistic; Racket also has a function called first that does the same thing.  If it makes things clearer to you, use that one instead.<br>

<br></div>If using functions like regexp-match* and car is giving you trouble in your program, I suggest playing around with them in racket or DrRacket, outside of any program.  Just apply regexp-match*, car, and any other functions you want to learn more about, to different inputs and see what results you get.  That should give you a clearer idea of how to put them together in your program.  It will also give you a starting point for asking more concrete questions about specific inputs and outputs the rest of us can look at, try ourselves, and explain.<br>

<br></div>For instance, see what (regexp-match* &quot;[abc]+&quot; &quot;banana&quot;) produces.  Also see what (car (list 1 2 3)) produces.  Try string-&gt;list and list-&gt;string if you&#39;re curious to see how they work, too.<br>

<div><br>When you&#39;ve got a handle on how each function works individually, you can get back to your program.  Write lots of tests for your program, and break your program up into smaller &quot;helper&quot; functions, and write tests for them too.  All these steps will make it much easier to see what each function is doing, and if the output isn&#39;t what you expected it to be, these steps will help you figure out where things went wrong and why.<br>

<br></div><div>Thanks for your question, feel free to ask more if you have them.  Good luck!<br></div><div><div class="gmail_extra"><br clear="all"><div>Carl Eastlund<br><br></div><div>P.S. I know this isn&#39;t a simple &quot;regexp-match* works like this&quot; answer.  Your question is actually several questions -- what kind of output does regexp-match* produce, how does one convert between lists and strings, how does the function car work, and so forth.  I hope the process above will help you work through some of the complexity and get to some simpler, more direct questions that are easier to tackle.  Sorry if this feels like a bit of a runaround, but I think you&#39;ll get a handle on it pretty quick!<br>

</div><br><div class="gmail_quote">On Thu, Jul 18, 2013 at 2:29 AM,  <span dir="ltr">&lt;<a href="mailto:m0nastic@tengulabs.com" target="_blank">m0nastic@tengulabs.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi, I&#39;m super new to Racket, but had what I hope isn&#39;t too<br>
embarrassingly easy of a question.<br>
<br>
I&#39;m writing a program that parses SMTP headers in order to automate some<br>
business-y workflow. I managed to put together a series of<br>
&quot;regexp-match*&quot;s to parse out the specific identifiers I was looking for<br>
(although truth be told, mail headers are surprisingly nonstandard even<br>
within a single message), and ran into an error later when trying to<br>
string-append them. I eventually discovered by process of elimination<br>
(after trying string?, etc. to figure out how the results of a regexp<br>
are stored) that they were a list. I tried list-&gt;string and a few other<br>
methods to covert them, but wasn&#39;t having any luck.<br>
<br>
I eventually discovered that I could sort of cheat, by just wrapping the<br>
regexp-match function with a car (which worked, because this particular<br>
list only had one element), and then it was usable from then on (and<br>
validated true from &quot;string?&quot;).<br>
<br>
So, my actual question is two-fold. First, It seems like I must have<br>
missed some pretty obvious way to capture the initial regex match as a<br>
string, but I&#39;m not sure what it was.<br>
<br>
And secondly, and actually what I&#39;m more curious about, why does it<br>
become a string when wrapped by car? I would have presumed that car<br>
would leave structures as a list.<br>
<br>
Again, I apologize if this is something dead-simple, but I really did<br>
spend a good portion of the day stuck in &quot;regex-hell&quot;, and so was<br>
curious.<br>
<br>
-Chris<br>
<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></div></div>