right bracket as literal in regular expression
Rajkumar Rathinam, January 17, 2024 - 6:03 am UTC
Yes, the right bracket will be treated as literal in regular expression only if it is used in first position in the list. Otherwise it won't be treated as literal and will result null value for regexp_substr function.
Example 1 : (if ] is used other than first position)
select regexp_substr('raj k[um]ar','^[a-zA-Z[:space:]\\]\\[]{3,20}$') from dual
Result will be below Error :
ora-12726 unmatched brackets in regular expression
Example 2: (Solution for Example 1)
select regexp_substr('raj k[um]ar','^[]a-zA-Z[:space:]\\[]{3,20}$') from dual ;
Output : raj k[um]ar
January 17, 2024 - 10:48 am UTC
Good point