Skip to content

Instantly share code, notes, and snippets.

@ronaldxs
Created January 20, 2017 01:15
Show Gist options
  • Save ronaldxs/35224401d427305afbf7ea03a75edb8e to your computer and use it in GitHub Desktop.
Save ronaldxs/35224401d427305afbf7ea03a75edb8e to your computer and use it in GitHub Desktop.
use Test;
grammar IP-or-reg-name {
token host_1 { <IPv4ish> | <reg-name_1> };
token host_2 { <IPv4ish> | <reg-name_2> };
token IPv4ish { <digit>+ '.' <digit>+ '.' <digit>+ '.' <digit>+ }
token reg-name_1 { <unreserved_1> * }
token reg-name_2 { <unreserved_2> * }
token unreserved_1 { <[\-._~] +[A..Za..z] +digit> }
token unreserved_2 { <[\-._~] +[A..Za..z] +[0..9]> }
}
is IP-or-reg-name.parse('1.2.3.4', :rule<host_1>).keys[0], 'IPv4ish',
'Match using variant of existing rules OK';
is IP-or-reg-name.parse('1.2.3.4', :rule<host_2>).keys[0], 'IPv4ish',
'Match with small and valid change fails apparently caused by LTM';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment