Regular expression question.

Asked 1 years ago, Updated 1 years ago, 86 views

I have a question about changing the string to a regular expression.

"It's seven. 12, 2016" String

"December 7, 2016"

How do I change to? I'm going to use re.sub function and I'm wondering how to make a regular expression.

regex python

2022-09-22 20:33

1 Answers

Simply, I think you can match the part with the numbers.

import re

message = "7. 12, 2016"
m = re.sub(r)(\d+).\s+(\d+),\s+(\d+)",r"\3year\February \1",message)
print(m)

Other


2022-09-22 20:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.