Created
April 11, 2014 19:42
-
-
Save yuitest/10495655 to your computer and use it in GitHub Desktop.
https://gist.github.com/yuitest/4698171 の Python バージョン。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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