I have a Perl example that seems exceptionally messy and inefficient when I attempt the same task in Python. Can someone that has better grasp in Python workings comment on how to simplify the python snip to be more similar to the Perl example in simplicity and coding fluff? Both these snips (Perl and Python) produce equivalent results. The key focus is the test then extraction of the regex within the parenthesis. The Python case seems to require the regex to be processed twice.
#Perl Example:
elsif ($teststring =~ m/^([0-9\.]+)[Xx]$/)
{
$ExtractedVa = $1;
}
#Python Example of how to implement the perl functionality above:
elif (re.search(r"^([0-9\.]+)[Xx]$",teststring)):
parts=re.search(r"^([0-9\.]+)[Xx]$",teststring)
ExtractedVa=float(parts.group(1)) # Convert from string to numeric