human
How to match beginning of string or character in Python
assistant
Here is some code to find float number proceeding sub-string `par` in string `dir`

float(re.findall('(?:^|_)' + par + '(\\d+\\.\\d*)', dir)[0])

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.