I am trying to match a whole string, to be an integer number.

My thinking is, that an integer starts with a non zero digit and then goes 
on with an arbitrary number of digits (including zero).
I put it in a regexp as follows:

(regexp-match #rx"[1-9]+[0-9]*" (current-input-port))

But this is not correct, as Racket will try to match this anywhere in the 
string. For example it will give me the list containing "1" as a result 
when I input "01". I have to specify, that it shall match the whole string. 
So I add ^ and $ to it:

(regexp-match #rx"^[1-9]+[0-9]*$" (current-input-port))

But when I try this on the REPL, it never stops wanting to receive more 
input. No matter how many times I press the enter key, it only jumps to a 
new line, expecting more input.
under 4.7.1 circumflex and dollar sign are said to be start and end, so I 
am not sure what I am doing wrong.
Is it the fact that the input stream does not really end and begin?

When I try:

(regexp-match #rx"[1-9]+[0-9]*" (read-line (current-input-port) 'any))

I get immediately #f, as if I already entered something. (OK I pressed 
enter to run that line of code …)

How do I solve this problem?

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.

Reply via email to