I'm trying to return My.Name
from the string: one.test.two=My.Name
As I understand I will need to use the ?<!
operator. The problem is that the "=" is left in the match using the following regex:
import re
print(re.search("(?<!(one.test.two=))?=(.*)", "one.test.two=My.Name"))
ie i return =My.Name
, as opposed to My.Name
. Please help me to understand why this is happening, and why I am not getting the desired result.
You can use a simpler regex:
re.search(r'.+=(.*)', 'one.test.two=My.Name').group(1)
We're only interested in whatever it's to the right of the =
character.