Forum Stats

  • 3,769,554 Users
  • 2,252,976 Discussions


regular expression in sql with mandatory and optional charcters and minimum 3 chr length

User_NPWZ2 Member Posts: 1 Red Ribbon


I wantto write an regular expression pattern where input string should match if it optionally has special charcters: &'.-\/:;`~_$space

and mandatorily it should have aphabets A-Za-b. Also length of string should be minimum 3 char

I tried..

select 1 from dual where regexp_like(' A ', '[&?\''?.?-?\\?\/?`?:?;?_?~?`?[:space:]?[A-Za-z]]{3,}')

Here when i provide '  ' (3 spaces) it is giving output as 1. whereas it should give null

My expected output is:

when input ' A ' output 1

when input '  ' output null

when input 'A ' output 1

when input ' A' output 1