regex - Checking for a pure string using regexp_like -
i need check "substring of first 6 characters" of input string pure string.
declare p_str varchar2(30) := 'abcd1240'; l_result varchar2(20); begin if regexp_like(substr(p_str,1,6), '[[:alpha:]]') dbms_output.put_line('it pure string'); else dbms_output.put_line('it alphanumeric'); end if; end; /
i can see first 6 characters of string abcd1290 alphanumeric contains 12. but, output printed says otherwise.
am doing wrong "alpha" in regexp_like ? thought alpha supposed pure characters , not numbers. here, abcd1290 should give me: alphanumeric output. abcdxy90 should : pure string
try this:
declare l_res varchar2(100); begin in (select 'abcdef123' val dual union select '123abc123' dual union select '123456abc' dual) loop if regexp_like(i.val, '^\d{6}') l_res := 'alpha'; else l_res := 'numeric'; end if; dbms_output.put_line(i.val || ' ' || l_res); end loop; end; 123456abc numeric 123abc123 numeric abcdef123 alpha
Comments
Post a Comment