From: Axel Schmalowsky Date: 2009-07-14T16:18:28+09:00 Subject: Re: a regex that does not contain comma -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sijo Kg wrote: > Hi > Could anybody please tell how to write the validates_format_of a > string(in rails) which is only valid when it does not contain a > comma.For example > > The are valid > > hi welcome > Hello > h123 kk > hh gg hh > > The are not valid > > Hello, > Hi , world > Hello,welcome > You could try sth like this: unless ( string =~ /((?>\w+\s*(?=,))+)/ ) do something end If the regexp above matches, than there's a comma somewhere in your string. > Thanks in advnce > Sijo - -- Freundliche Gr����e / Kind regards Axel Schmalowsky 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: aschmalowsky@df.eu 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 iEYEARECAAYFAkpcMT4ACgkQsuqpduCyZM1tjgCgujiBTLeyswnRISX4aG1iCdlm 8GYAnAkdjV2Oc8XiKvzjlWMaVnLsCN7d =5vUO -----END PGP SIGNATURE-----