Question: I have data that has strings like 'ms2p5', 'ms3', 'ms10' for which I need to extract the digits as convert to numbers as follows.

```
'ms2p5' => 2.5
'ms3' => 3
'ms10' => 10

```

I tried the below regex and it is able to get the match. One issue is with values having a character in the middle of the extracted string like '2p5'. What is the right approach to have a generic function that handles all these cases well while converting them into numeric values? 

```
import re
re.search(r'\d+[p]*\d*', str).group() 

```

Answer: 
Use `str.join` with `re.findall`:

```
los = ['ms2p5', 'ms3', 'ms10']
print([float('.'.join(re.findall('\d+', i))) for i in los])

```

Output:

```
[2.5, 3.0, 10.0]

```
If the strings all follow the examples you provide, I'd probably just do: 

```
x = 'ms2p5'
float(x[2:].replace('p', '.'))

```