String matching: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 248: | Line 248: | ||
loc = "abab".find("ab") #returns 0 |
loc = "abab".find("ab") #returns 0 |
||
loc = "abab".find("ab",loc+1) #returns 2</lang> |
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}}== |
=={{header|Retro}}== |