I am struggling to fix the following regular expression to extract key-value pairs from file names. File names are of the format:
FilePrefix_Key1=<0 or more spaces><optional +, - or none><optional decimal or integer value><0 or more spaces><unit/setting which may contain letters, and math operators e.g., slash>_Key2= ... .ext
I wrote the following regular expression (https://regexr.com/5lflm)
(?<=Set= *)([+-]?\d*\.?\d+?) *([A-Za-z-+^/*()]{1}[A-Za-z0-9-+^/*()]*)(?= *_|\.|\s)
but it fails on the following text as "High" is not returned in the second capture group.
FilePrefix_Speed= 3.5 kmph_Accel= +0.5 m/(s^2) _Height=+7m_Set=High.txt
Although it can be captured correctly by changing ([+-]?\d*\.?\d+?) to ([+-]?\d*\.?\d*?) but then "Accel" key is not captured properly (only +0 is returned in the second capture group).
Could you please help me to fix this expression?
Thank you!