I want to create regexp that takes these values:
number:number [P]or [K]either both or nothing, and now he can repeat it again, separated by a separator [ + ], for example, valid values:
15:15
1:0
1:2 K
1:3 P
1:4 P K
3:4 + 3:2
34:14 P K + 3:1 P
What I created:
([0-9]+:[0-9]+( [K])?( [P])?( [+] )?)+
There is only one error in this example. It takes on the value:
15:15 K P +
which should not be allowed.
How do I change it?
UPDATE:
I forgot to mention that it could be KP or P K. Or the values are valid
1:4 K P
source
share