Skip to content

Instantly share code, notes, and snippets.

@yuitest
Created April 11, 2014 19:42
Show Gist options
  • Save yuitest/10495655 to your computer and use it in GitHub Desktop.
Save yuitest/10495655 to your computer and use it in GitHub Desktop.
https://gist.github.com/yuitest/4698171 の Python バージョン。
# coding: utf-8
from __future__ import unicode_literals, print_function
def partial_contains(text1, text2):
index = 0
for char in text2:
index = text1.find(char, index)
if index < 0:
return False
return True
if __name__ == '__main__':
print(partial_contains('ゲームボーイアドバンス', 'ムボードン')) # True
print(partial_contains('あいう', 'ぬ')) # False
print(partial_contains('お前のものは俺のもの', 'お前は俺のもの')) # True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment