Forum Stats

  • 3,740,935 Users
  • 2,248,347 Discussions
  • 7,861,512 Comments

Discussions

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

User_NPWZ2
User_NPWZ2 Member Posts: 1 Red Ribbon

Hi


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

Sign In or Register to comment.