Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Search a word in a string
Lloyd Linklater
11/6/2008 2:34:00 PM
Ganesh Ganesh wrote:
> Is there any ruby supported methods is there for searching a word in a
> particular string
>
> For Example "Hi this is for test"
> i need to search "Hi"
Wouss is correct that a simple search would have shown you the answer.
Still, I ask questions here and it is my turn to help with an answer.
With something like this:
"Hi this is for test".index('Hi')
you get a nil if there is no match and the starting point of the string
found if there is one.
e.g.
puts 'string found' unless "Hi this is for test".index('Hi') == nil
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Search a word in a string
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password