How to find the first space?
cwitts at gmail.com
Tue Jun 10 08:47:14 CEST 2008
On Jun 9, 5:02 pm, Johny <pyt... at hope.cz> wrote:
> How can I find the first space using regex?
> For example I have text
> Text=' This is a sample '
> The last space I can remove by
> but I do not know how to remove the first space.
> Can anyone help?
If it's leading spaces you're worried about you can use the .lstrip()
method, if you want to find the first space you can use .index(' ') to
get the position of it and do with what you want.
More information about the Python-list