Re: [racket-users] Regexp question matching a whole string

2018-04-27 Thread Zelphir Kaltstahl
Yep, that works, thank you. I did not know that EOF alone could be there. On Monday, April 23, 2018 at 2:16:52 AM UTC+2, Sam Tobin-Hochstadt wrote: > > Typed Racket is reminding you that `read-line` can produce EOF. If you > handle that (for example, with `(assert something string?)`) then it >

Re: [racket-users] Regexp question matching a whole string

2018-04-27 Thread Zelphir Kaltstahl
That is an interesting and probably much better way to do it. Of course I did remember -0/42 … *clears throat* (not) :D Thank you! On Monday, April 23, 2018 at 12:03:38 AM UTC+2, Matthew Butterick wrote: > > On Apr 22, 2018, at 1:40 PM, Zelphir Kaltstahl > wrote: > > Ah OK, I understand that add

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Sam Tobin-Hochstadt
Typed Racket is reminding you that `read-line` can produce EOF. If you handle that (for example, with `(assert something string?)`) then it works correctly. Sam On Sun, Apr 22, 2018 at 4:40 PM, Zelphir Kaltstahl wrote: > Ah OK, I understand that additional newline. Since the code matching the >

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Matthew Butterick
> On Apr 22, 2018, at 1:40 PM, Zelphir Kaltstahl > 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

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Pierpaolo Bernardi
On Sun, Apr 22, 2018 at 10:40 PM, Zelphir Kaltstahl 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 negat

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Zelphir Kaltstahl
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.) ~~~ (regexp-tr

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Matthew Flatt
At Sun, 22 Apr 2018 14:54:26 +0200, Zelphir Kaltstahl wrote: > I am sorry, I think I am still misunderstanding it. > > When I try: > > (regexp-try-match #rx"^[1-9]+[0-9]*$" (current-input-port)) > > It also results immediately in: > > #f Using stdin both for reading an expresion and getting i

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Zelphir Kaltstahl
I am sorry, I think I am still misunderstanding it. When I try: (regexp-try-match #rx"^[1-9]+[0-9]*$" (current-input-port)) It also results immediately in: #f > "^" doesn't match the beginning of the input Is there something else I should use to start matching from the beginning of whatever

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Matthew Flatt
Try `regexp-try-match`. The `regexp-match` function on an input port consumes non-matching input, which means that it consumes all input if a pattern that starts "^" doesn't match the beginning of the input. (This behavior is mentioned in the docs for `regexp-match`, but the docs have to say so m