Right now my regex is something like this:
[a-zA-Z0-9] but it does not include accented characters like I would want to. I would also like - ' , to be included.
Special Regex Characters: These characters have special meaning in regex (to be discussed below): . , + , * , ? , ^ , $ , ( , ) , [ , ] , { , } , | , \ . Escape Sequences (\char): To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash ( \ ).
Basically (0+1)* mathes any sequence of ones and zeroes. So, in your example (0+1)*1(0+1)* should match any sequence that has 1. It would not match 000 , but it would match 010 , 1 , 111 etc. (0+1) means 0 OR 1.
It means that it is not capturing group.
Accented Characters: DIY Character Range Subtraction
If your regex engine allows it (and many will), this will work:
(?i)^(?:(?![×Þß÷þø])[-'0-9a-zÀ-ÿ])+$
Please see the demo (you can add characters to test).
Explanation
(?i)
sets case-insensitive mode^
anchor asserts that we are at the beginning of the string(?:(?![×Þß÷þø])[-'0-9a-zÀ-ÿ])
matches one character...(?![×Þß÷þø])
asserts that the char is not one of those in the brackets[-'0-9a-zÀ-ÿ]
allows dash, apostrophe, digits, letters, and chars in a wide accented range, from which we need to subtract+
matches that one or more times$
anchor asserts that we are at the end of the stringReference
Extended ASCII Table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With