"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I am looking for the best and efficient way to replace the first word > in a str, like this: > "aa to become" -> "/aa/ to become" > I know I can use spilt and than join them > but I can also use regular expressions > and I sure there is a lot ways, but I need realy efficient one
Assuming you know the whitespace will be spaces, I like find: new = "/aa/" + old[old.find(' '):] As for efficiency - I suggest you investigate the timeit module, and do some tests on data representative of what you're actaully going to be using. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list