> On Apr 22, 2018, at 1:40 PM, Zelphir Kaltstahl <zelphirkaltst...@gmail.com> > wrote: > > Ah OK, I understand that additional newline. Since the code matching the > regex is run before that newline gets in, the newline will be on the > input port. > > In DrRacket I observe the following: > > (I remembered that there are negative numbers :D and my regex got a bit > more complicated.)
Parsing numbers with regex is prone to error, because you'll often miss edge cases. For instance, did you remember that -0/42 is an exact integer? A nice way to avoid these headaches is to delegate the heavy lifting to `read`, and then just test the result value: #lang racket (for/first ([val (in-port read)] #:when (exact-integer? val)) val) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.