Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
    
You have given what you want, but not a problem. What have you tried, how didn't it work? Did you get an error or incorrect results? –  Lattyware May 6 '13 at 1:12

1 Answer 1

up vote 2 down vote accepted

Use list comprehension and slicing:

>>> 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']
share|improve this answer
    
awesome ! thanks –  nguyên May 6 '13 at 1:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.