-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David A. Black wrote:
string = <<-EOM
Hi.
I have, at a minimum, two commas.
Bye.
EOM
p “Match!” if /^[^,]*$/.match(string)
=> Match!
Technically, the regexp above always succeeds (iirc).
Even though the regexp is delimited by ^ and $,
it matches always as along as the string against which the regexp is
applied
does not consist of only a single comma (’[^,]* – match everything
(including nothingness) but a comma).
So, I guess it’s better to simply use /,/.
You’d want to use \A and \z, rather than ^ and $ (which delimit lines,
rather than the whole string).
But if you’ve already tested for /,/, then you should be able just to
have an else clause in your case statement, to cover cases where /,/
didn’t match.
David
Freundliche Grüße / Kind regards
Axel S.
Platform Engineer
domainfactory GmbH
Oskar-Messter-Str. 33
85737 Ismaning
Germany
Mobil: +49 (0)176 / 10246727
Telefon: +49 (0)89 / 55266-356
Telefax: +49 (0)89 / 55266-222
E-Mail: [email protected]
Internet: www.df.eu
Registergericht: Amtsgericht München
HRB-Nummer 150294, Geschäftsführer:
Tobia Sara Marburg, Jochen Tuchbreiter
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkpcgykACgkQsuqpduCyZM042ACg3fdmTo01wS6DS6bT+416JE2/
deEAoMyfbm2wp81cKDtk7wNp9xXgnzcP
=dFl8
-----END PGP SIGNATURE-----