I have written a python script (my very first) that accepts input of a string and then uses re.search to create groups from the string for later use.
The input string would like something like this:
NSC_sdiakjfean=ffffffff3c19594d45525d5f4f58455e445a4a423660
The re.search I’m currently using is:
s = re.search('NSC_([a-zA-Z0-9\-\_\.]*)=[0-9a-f]{8}([0-9a-f]{8})[0-9a-f]{24}([0-9a-f]{4})',name)
The problem that I’ve found is that sometimes the input I want to use is missing this section [0-9a-f]{24} so my python script crashes with an exception and doesn’t capture the last group.
Is there any regex (yes I’ve googled this lots) that I can use for the last group start at the end of the input string and just group the last 4 digits?
Thanks in advance.
Adam
$matches the end of the string.So the expression you may want is