Reputation: 81
I want to compare string with parentheses as ex.
String: @required (
abc ( xyz:54554 )
)
Then If I want to confirm that @required ()
should be there then above one should return true or we can say match.
Current regex only works and return "abc ( xyz:54554 )
" instead of whole.
Tried: \([^()]*\)
Upvotes: 0
Views: 52
Reputation: 2948
You can achieve what you want using start and end tokens. I recommend you trim()
your input first.
/^@required\s*\((.*)\)$/
https://regex101.com/r/JPyDhj/1
Upvotes: 1