I need to write a regular expression in order to be able to match the following patterns:
IF:en0
IF:en0:10.94.80.78
IF:en11
IF:en11:10.94.80.78
The regular expression i wrote in PL SQL was
IF REGEXP_LIKE(input_str,
'^IF:en([0-9])([:]?)((25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})$') then
DBMS_OUTPUT.PUT_LINE('Match');
END IF;
This works fine. But I want to know if there is a way in which I can make the pattern for ip address
((25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})
as a variable above and use something like
ipaddrpattern :=
'((25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})';
IF REGEXP_LIKE(input_str,
'^IF:en([0-9])([:]?)||ipaddrpattern||$') then
DBMS_OUTPUT.PUT_LINE('Match');
END IF;
I tried the above but didn't work. Can someone please help me with the syntax?