regex pattern concatenation in python

I have the following pattern to match percentage from the below cases

76.39% (based on 206 issue)
1.23% (based on 197)
81.06% based on 206,390,020 fully  issue
12.02
16.59
81.61%
45
24.812
51.35
19348952
88.22
0
000
021
.85%
100

Expected:

76.39
1.23
81.06
12.02
16.59
81.61
45
24.812
51.35

88.22
0
000
21
.85
100
pattern1= r'(d+.d+%)'
df['var']=df['var'].astype(str).str.extract(pattern1)[0]


pattern2 = r'^(?:0{0,})((?:[1-9]{1,2}|100)?(?:.d+)?)%?$'
df['var']=df['var'].astype(str).str.extract(pattern2)[0]

Both of these patterns match all the cases (pattern 1 matches the first 3 cases and pattern 2 the rest). Is there any way they can be combined into single regex pattern to match all the cases?

Your help is appreciated. Thank you.

Read more here: Source link