2021年4月1日星期四

Python substring from beginning and return index (have duplicate case)

I have a long string and a list of substring of the corresponding long string.

Example 1:    String: " This is paragraph one "    List of substring: ["This", "is paragraph", "one"]    I need to return the index for the corresponding substring    Result: [[0,4], [5, 17], [18, 21]]      Example 2:  (Could have more white space and could have duplicate substring)    String:  "  This is a book       a book.  "    List:  List of substring: ["This", "is a", "book", "a", "book"]    Result: [[0,4], [5, 9], [10, 14], [21,22], [23, 27]]  

Thanks in advance!!!!

https://stackoverflow.com/questions/66913550/python-substring-from-beginning-and-return-index-have-duplicate-case April 02, 2021 at 09:51AM

没有评论:

发表评论