I am trying to find a regex to include all the 4 entries.
I tried this
^[a-zA-Z+-]+
but it matched only 3 not the SAP+30
The entries are:
SAP+
,
SAP+30
,
C+
,
ABC
Can anybody suggest
>Solution :
The match digits, you can use the range 0-9
in the character set (or \d
on its own). Although from the looks of your examples, you might be better with a more specific regular expression rather than one that matches anything with these characters:
^[A-Za-z]+(\+\d*)?$
This looks for at least one letter followed by either nothing or one +
character and then any number of digits.