Search code examples
regexreplacenotepad++

Delete parentheses around a text


I have a long file which contains texts and there is a particular type of text which is 24 character long (it can be lowercase alphabet or number),it starts and ends with " and there are parentheses around this. One of these kind of row looks like this:

"something": ("qwertyuiopasdfghjklz1234"),

and I would like to get:

"something": "qwertyuiopasdfghjklz1234",

I would like to remove the parentheses. I have the following regex: ([a-z0-9"]{26}) which finds this expression but I don't seem to find a way to figure out what to write to replace the row in order to delete the parentheses.


Solution

  • You may use

    (:\h*)\(("[a-z0-9]{24}")\)(,)
    

    Replace with $1$2$3, see the regex demo.

    Details

    • (:\h*) - Group 1 ($1): : and 0 or more horizontal whitespaces
    • \( - a ( char
    • ("[a-z0-9]{24}") - Group 2 ($2): ", 24 lowercase ASCII letters or digits and then a "
    • \) - a ) char
    • (,) - Group 3 ($3): a , char.