How to make a select that returns only the strings that contain at least 2 alphabetic characters. The string can contain any combination of characters
ID Name
1 John
2 John2
3 2
4 /
5 12-
6 JW
7 Jw1
8 ,
where regexp_like(str, '[a-z].*[a-z]', 'i');
should do it.
The 'i'
parameter (specific to Oracle SQL regex functions) makes it case-insensitive.
Explanation: https://regex101.com/r/OYec02/1
If you're using 11g or later (and you should be) you can use regexp_count()
to do this:
where regexp_count(txt, '[a-z]', 1, 'i') >= 2
This is handy where the number of characters you want to match is larger than two.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.