sqlregexoraclespecial-charactersregexp-like

Regexp strings with specific characters


I would like to create a query where I select all records which may contain letters, digits and special characters from group of 3 special characters: / " ,

I've tried '[0-9a-zA-Z(\-\/\")]' but something like 'a+' works


Solution

  • Something like this?

    SQL> with test (col) as
      2    (-- valid values
      3     select 'Little12'     from dual union all
      4     select 'Foot/15'      from dual union all
      5     select '"London",UK'  from dual union all
      6     -- invalid values
      7     select '25+ miles'    from dual union all
      8     select 'me@gmail.com' from dual
      9    )
     10  select col
     11  from test
     12  where regexp_like(col, '^[a-zA-Z0-9/",]*$');
    
    COL
    ------------
    Little12
    Foot/15
    "London",UK
    
    SQL>