regexregex-negation

regex - find any block between curly brackets that contains one or more non-numeric characters


I want to find in a text all ocurrences of blocks between curly brackets, that contains any non-numeric character.

For example, in the text:

something {34dj 4s} and something else {335} and more {dgw} and {6} or whatever

it should match 2 items: {34dj 4s} and {dgw}

I have tried with this (im using it in .net c#) but it will match only ocurrences that ONLY contains non-numeric characters...:

@"{[^0-9]*}"

Solution

  • You may use this regex to match {...} with at least one non-digit in between:

    \{[0-9]*[^0-9}][^}]*}
    

    RegEx Demo

    RegEx Details: