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
Post a Comment