Thursday, 15 March 2012

sql - Oracle regular expression for number range and length -


I need to validate the given list of IP addresses. IP address 1.0.0.0 to 255.255.255.255

Below I've done something:

 with  T (Val) AS (Select '123.1235.231.234.12' from Dual Union 'Dual All '011.' from '011' with '123123' dual union from union ', all choose' 000. 'Select' 123123 'from dual union' Select all from dual union '1920.16. 1.65 'dual union' 255.256.1.65 ' Choose from Double Select) * from where REGEXAPPLILEE (Val, '^ [1- 9] {1,3}. [0- 9] {1,3}. [0- 9] {1,3}. [ 0- 9] {1,3} $ ') and REGEXP_SUBSTR (Val,' [1- 9] {1,3} ', 1,1) between 1 and 255 and regexp_substr (Val,' [0- 9] Between 0 and 255 and REGEXP_SUBSTR (Val, '[0- 9] {1,3}', 1,3) between 0 and 255, and REGEXP_SUBSTR (Val, '[1,3] between {1,3}', 1,2) 0- 9] {1,3} ', 1,4) between 0 and 255  

Please help with the data I tested right away if I have a simple regular expression I can do this together.

Thank you in advance

There is an error in your regex, Code> 10.0.0.0 does not match for example.

Change it to:

  '^ [0-9] {1,3} \. [0-9] {1,3} \. [0-9] {1,3} \. The test followed by [0-9] {1,3} $ ' 

0.0.0.0

Will reject

No comments:

Post a Comment