Reputation: 29
I have this specific string : Oxidation mark (2-3,20mm- 110mm) , in dataframe column . The text between parenthesis can be anything .
I tried to extract this by the below code:
str.extract('(Oxidation mark )[\(][.]*[\)]')
But its giving NaN
.
Upvotes: 0
Views: 286
Reputation: 627087
You can use
\b(Oxidation\s+mark\s*\([^()]*\))
See the regex demo.
Details
\b
- a word boundary(Oxidation\s+mark\s*\([^()]*\))
- Group 1:
Oxidation
- a word\s+
- one or more whitespacesmark
- another word\s*
- zero or more whitespace chars\([^()]*\)
- (
, zero or more chars other than (
and )
and then a )
char.Upvotes: 1