Deepti Kakade
Deepti Kakade

Reputation: 3213

Write a Regex to find a brackets which only contains the alphabets

Consider the following string and I want to replace a brackets which contains alphabets with space:

str = (abc pqr xyz (tttt) 2018(2))

I am expecting the following output:

str_op =  abc pqr xyz tttt 2018(2)

How to write a regex for above example

Upvotes: 0

Views: 40

Answers (1)

vks
vks

Reputation: 67988

(\([^\D]*\))|\(|\)

You can use this and replace by $1.See demo.

https://regex101.com/r/sS2dM8/27

Upvotes: 1

Related Questions