Alle 22:21, domenica 19 novembre 2006, Luca S. ha scritto:
This always returns “OK”
Any suggestions what goes wrong here. And is this the way to check the
content of a string ?
Thanks a lot
Even when there’s no match, String#scan returns an array, so your is
true. To make it work, you should use
As for your second question, it depends on what exactly you want to do.
the correct form if you need to get all the numbers in the string,
of their position or any other thing (by the way, if you want to match a
digit in a regexp, you can use /\d/). If you simply want to check
string contains a digit, you can use String#match or =~ with the /\d/
If you need more control on the scanning, you can use the StringScanner
I hope this helps