0

My web site run on gae, I want to implement a input-tag-box like tags input box in SO, but search on gae required user enter whole word for match.
Example hello world required user enter world or hello for result hello world and I want to when user enter some word like he or hel then result hello world.

I looking for a function for parse a string into multi sub string (implemented in python)

Ex: hello world --> he hel hell hello wor worl world.

Any other solution are welcome.

Thanks

4

1 回答 1

2

使用列表理解和切片:

>>> strs= "Hello world"
>>> [y for x in strs.split() for y in (x[:i] for i in  xrange(2,len(x)+1)) ]
['He', 'Hel', 'Hell', 'Hello', 'wo', 'wor', 'worl', 'world']
于 2013-05-06T01:28:50.130 回答