Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion parser.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
def word_in_string?(word, string)
# implement with your code here
regex = /(\A|\W|[_])#{word}(\W|\z|[_])/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the \b regex symbol.


if(regex =~ string)
:yes
else
:no
end
end
1 change: 1 addition & 0 deletions word_in_string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'pry'

describe "word_in_string?" do

context "returns symbols :yes and :no" do
it "should return :no for word_in_string?('grow', 'growler')" do
expect(word_in_string?('grow', 'growler')).to eq :no
Expand Down