I am trying to find a regular expression that will help me check the Blood Group field , which should only accept A [+ -], B [+ -], AB [+ -] and O [+ -].
Here I came up with regex (and tested using Regex Tester ):
[A|B|AB|O][\+|\-]
Now this pattern successfully matches A, B, O [+ -], but does not work with AB [+ -].
Can someone suggest a regex that will serve my purpose?
Thank you t ^ e
Try:
(A|B|AB|O)[+-]
, . , , . +- , regexy.
+-
, , , , , :
^(A|B|AB|O)[+-]$
, "helloAB + asdads", .
[] , " ". () :
(A|B|AB|0)(\+|-)
(, (A|B|AB|O)), . , ( ). [-+] , (A|B|AB|O)[-+] "AB+". , (AB|A|B|O)[-+] ( ).
(A|B|AB|O)
[-+]
(A|B|AB|O)[-+]
"AB+"
(AB|A|B|O)[-+]
, , : (?:AB|A|B|O)[-+].
(?:AB|A|B|O)[-+]
, , - , , : ^(?:AB|A|B|O)[-+]$. . ^ , , . , $ , . ( % 100): \A, \Z \Z. , \A , \Z , \Z .
^(?:AB|A|B|O)[-+]$
^
$
\A
\Z
^ (A | B | AB | O) [+ -] $? This will give the correct result.
For the case insensitive to the html pattern attribute, you can try this
([AaBbOo]|[Aa][Bb])[\+-] <input type="text" maxlength="3" pattern="([AaBbOo]|[Aa][Bb])[\+-]" required />
Source: https://habr.com/ru/post/1710658/More articles:Website Coding - pythonWriting a unit test to permanently create and delete data - c #SELinux and Java - javaAsp.net Time Management Guidelines - inputFind the lowest common parent in a SQL recursive table - sqlTLBIMP.EXE - Error TI0000 - * .dll is not a valid type library - deploymentConnecting to Team Foundation Server (TFS) with proxy authentication - tfsShould I rewrite the end of the Webapp interface in Erlang? - erlangС#: Явное указание интерфейса в методе реализации - access-modifiersHow to call NetworkStream.Read () without blocking? - c #All Articles