M
Mmcolli00 Mom
File.open("patientrecords.txt", 'r') do |p|
if p.gets =~ /%{2,3}PersonID/ then
puts "PersonID exist twice"
end
end
Hi.
This is supposed to tell me if there a line in my text file that
contains 'PersonID' at least 2 times and at most 3 times. I have been
playing with regular expressions and thinking {m,n} would help with
this. This snippet is used to show me if it will actually work. (Some
lines contain PersonID only once, I do not want to use those lines)
Thanks, MC
if p.gets =~ /%{2,3}PersonID/ then
puts "PersonID exist twice"
end
end
Hi.
This is supposed to tell me if there a line in my text file that
contains 'PersonID' at least 2 times and at most 3 times. I have been
playing with regular expressions and thinking {m,n} would help with
this. This snippet is used to show me if it will actually work. (Some
lines contain PersonID only once, I do not want to use those lines)
Thanks, MC