I'm trying to create a table where in the constraint is that the name to be added needs to be in the form "abc-123". I'm trying to do this by using CONSTRAINT pname CHECK(pname ~ '^[A-Za-z]+(?(?=\.)[a-z]+|)\-[0-9]*$')
. However, when I try to insert anything into the table (for eg. (1,'name-123','blue') it gives me the error invalid regular expression: quantifier operand invalid
and I'm unsure why or how to fix it.
Asked
Active
Viewed 4 times
0
-
Why not `^[A-Za-z]+-[0-9]+$`? What are the rules you try to implement in the regex? – Wiktor Stribiżew Nov 16 '20 at 23:57
-
That worked! Thanks! – SegmentationFault Nov 16 '20 at 23:59