Regex remove pattern from match

Tried to find an answer but didn't do it.

So let's say I have a line

12/01/2014 22:13 1,600/1,800 *or*
12/01/2014 22:13 100/200 *or*
12/01/2014 22:13 1,600/1,800 A *or*
12/01/2014 22:13 1600/1800 A

      

I need to get / 1800 or / 200 or / 1800 or / 1800

/(\d{1,3},)*\d+.?(\d{1,8}|)

      

this gives me 2 matches: example. / 1 800 and / 01/2014

I found a pattern to exclude dates:

(?!(0?[1-9]|1[012])([-/.])(0?[1-9]|[12][0-9]|3[01])([-/.])(19|20)\d\d)

      

but I don't know how to combine the two.

+3


source to share


2 answers


You can try the following regex to match only /1,800

or /200

or /1,800

or/1800

\/(?:\d,\d{3}|\d{3,4})\b(?=[^\d]*$)

      

DEMO

OR



\/(?:\d,\d{3}|\d{3,4})\b(?! \d)

      

DEMO

(?! \d)

This negative lookahead states that the characters following the numbers should not be a <space>

number either . So this match /01/2014

must fail as it follows a space and a number.

+1


source


.*(\/\S+)

      

This simple regex should work for you.



Watch the demo

+2


source







All Articles