I am trying to create a program where two strings are entered. If they match it returns the number of positions where they contain the same length 2 substring.
for example:string_match(‘xxcaazz’, ‘xxbaaz’) → 3 “xx” “aa” “az”
My question is what metacharacters should i use to validate
here is what i have come up with
puts "enter word"
a = STDIN.gets
a.chomp!
puts"enter word"
b = STDIN.gets
b.chomp!
if a == /word/ or b == /word/ then
puts str.match(/{a} {b}/) + "equal"
end
UPDATED ANSWER:
( Still spiked, but better )
ORIGINAL SPIKE:
This may get you off to a good start ( though it’s by no means bullet proof, just a quick spike ):