通常我使用
目前我有一个特殊情况。
str.find()
在Python中查找子字符串。目前我有一个特殊情况。
First I want to ignore the whitespaces For example
s1= ' first words s t r i n g last words ' s2= 'string' s3= 's tring' s4= any other combination with the spaces
I want find to return true when I search
s2
ands3
ins1
Secondly I want to get the starting and ending index of the substring within the original string
It could be that there are many spaces in the original string, for example
s1= ' first words s t r i n g last words '
I would like to have indices starting at
s
and ending atg
in the original string.
编辑1
为了澄清,在源字符串和目标字符串中,空格都是无关紧要的。
谢谢