How to Replace a Matching Parenthetical up to the First Closing Parenthesis

  • (Foo,1234567890) (bar)

    where the numerical string after Foo, can be any set of numbers, and where this sequence is repeated an indefinite quantity of times in a long list with or without including (bar) on each line.

    Task: You must replace (Foo,1234567890) without replacing any instance of (bar).

    The regular expressions on are not functioning, or else poorly explained in human language.

  • @Zetawilk

    Your request is kinda vague, at least to me, but let’s get the ball rolling:

    Find: \(\w+,\d+\) <----note the trailing space
    Search mode: (obviously) Reg exp

    Probably not what you want, but to me it works the way I understand the “spec” that has been presented.

  • I’m unable to edit the topic post for undisclosed reasons. The set of numbers after (Foo, can be in hexadecimal. I can’t possibly imagine what else you thought was “vague”.

  • Posts are only editable for 3 minutes.

    With the new spec, I would try:

    Find: (?i)\(\w+,[0-9A-F]+\)

  • Thank you very much for your assistance. This issue is now resolved.

  • @zetawilk, @alan-kilborn and All,

    @zetawilk, in your initial post, you said :

    Task: You must replace (Foo,1234567890) without replacing any instance of (bar)

    You’re not asking, here, for any commercial demand. Personally, I would have written, preferably :

    Request : replace (Foo,1234567890) without replacing any instance of (bar)

    and thanked, in advance, possible repliers, for their [free] help !

    Just remember it, in your next posts ;-))

    Best regards,


    P.S. :

    I just forgot your last post. So, let me temper my criticism because you did thank Alan for his answers !

Log in to reply