Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex to include +-digit

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading