Ruby string include? all characters -


is there in ruby returns true if string contains whole word, in case 'hello'. dont want include? returns true if pieces present:

   'hello whats up'.include? 'll'    => true 

> 'hownowbrowncow'['now']    => "now" # nil if not found 

and if want require word boundaries...

'hownowbrowncow'[/\bnow\b/]  => nil  

it doesn't matter if returns true or false, since other nil or false fulfill conditional test. if true , false, well, can turn arbitrary expression true or false number of ways, 1 way is:

'now'.nil?  => false !'now'.nil? => true 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -