Is there any regualar expressions,which Should not allow blank space as
the first character for my Department Name field.
any helps on this…
Thanks
Newb N. wrote:
Is there any regualar expressions,which Should not allow blank space as
the first character for my Department Name field.
Yes. Check out the regex documentation in the Pickaxe Book. Pay
particular attention to the following constructs: [], \s, and ^ (in both
its senses).
Or just use String#strip.
any helps on this…
Thanks
You’re welcome!
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
2009/6/18 Newb N. [email protected]:
Is there any regualar expressions,which Should not allow blank space as
the first character for my Department Name field.
any helps on this…
If you just want to check that the first character of the string is
not space (as opposed to stripping off leading whitespace) just check
the first character using fieldname[0]. Depending on your
requirements it may be more user friendly just to strip off whitespace
using strip or strip!
Colin
Gavin M. wrote:
[…]
If you’re specifically looking for a regepxp that will match any thing
that doesn’t start with a space then try: /^[^\s]/
I was trying not to spoon-feed the lazy.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Haha
Fair enough
Marnen Laibow-Koser wrote:
Gavin M. wrote:
[…]If you’re specifically looking for a regepxp that will match any thing
that doesn’t start with a space then try: /^[^\s]/I was trying not to spoon-feed the lazy.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Newb N. wrote:
Is there any regualar expressions,which Should not allow blank space as
the first character for my Department Name field.
any helps on this…
Thanks
If you’re specifically looking for a regepxp that will match any thing
that doesn’t start with a space then try: /^[^\s]/
If it returns nil, there’s a space, if not then there’s no space.
Otherwise I’d go with Colin’s approach.
Gavin