Philip Hallstrom wrote: >> Can Anyone help me with regular expression which checks the string, if >> it contains Leading whitespaces. >> example >> => admin >> it contains leading space with it. >> so i need to check it. >> pls help me. >> > > Read up on the Regex class and pattern matching in general... > > str = " some string with a leading space" > > if str =~ /^\s/ > puts "we have a leading space" > else " > puts "we don't" > end > Not directly related, but if you just need to remove the leading/ trailing spaces, you could use lstrip, rstrip and strip on strings.
Cheers, Mohit. 2/7/2009 | 2:25 PM. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

