Home > Net >  RegEx: Match all digits with minus sign
RegEx: Match all digits with minus sign

Time:09-30

I want to match in a text all digits that conatains the minus sign. Exemple:

      hallo my name is 12234567-2 i live in berlin 
      my mother 1234 is at home 7654321-7

My expected output is 12234567-2 and 7654321-7.

CodePudding user response:

Try the following:

\b[0-z]*-[0-z]\b

This should select any set of alphanumeric that contain a minus symbol.

CodePudding user response:

You can use this pattern:

\d -\d 

It matches one or more digits followed by literal - followed by one or more digits

  • Related