0

I have one string like following, how can I use re to split the string into I use re.find and sub that works but just take couple step any better

k = '12345567 I love this 1234 - One'
x = re.findall(r'^\d+ ', k)[0]
y = re.sub(x, '', k)
res = [x[:-1], y] # ['12345567', 'I love this 1234 - One']

1 Answer 1

2

Perhaps you can solve this by using the split function:

k = '12345567 I love this 1234 - One'.split(' ',1)
# ['12345567', 'I love this 1234 - One']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.