0
Regular expression
I want the regular expression that checks if the first and last words of a given string are same or not? Please answer as soon as possible!
4 ответов
+ 1
here the code to check that with rwgular expression:https://code.sololearn.com/cs97nAm7wLWr/?ref=app
+ 6
RegEx are best suited for finding *patterns* not really efficient in your task, at least as you described it.
You might want to consider another approach:
s = "Been there, where you've been"
temp = s.lower().split()
print(temp[0] == temp[-1])
# first equals to last
+ 2
Checking weather an email address is real
0
This regex can get the text if the first and last words are equal: (\w+)(\s\w+)+\s?(?=\1)\1