Jump to content

String matching: Difference between revisions

no edit summary
No edit summary
Line 248:
loc = "abab".find("ab") #returns 0
loc = "abab".find("ab",loc+1) #returns 2</lang>
 
=={{header|Ruby}}==
{{works with|Ruby|1.8.7}}
<lang ruby>'abcd'.start_with?('ab') #returns true
'abcd'.end_with?('zn') #returns false
'abab'.include?('bb') #returns false
'abab'.include?('ab') #returns true
'abab'.index('bb') #returns -1
'abab'.index('ab') #returns 0
'abab'.index('ab', 1) #returns</lang>
 
=={{header|Retro}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.