11-09-2011 12:36 PM - edited 03-16-2019 07:57 AM
I have a problem that seems like it should be pretty simple but I've been banging my head against the wall for a couple days now and still nothing. I'm trying to take a number pattern (7135551[2-4]..) and put a plus in front of it (make it an e.164 number). Consider the output below:
router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
router(config)#voice translation-rule 5
router(cfg-translation-rule)#rule 1 /^(7135551[2-4]..)$/ /+\1/
router(cfg-translation-rule)#end
router#test voice translation-rule 5 7135551212
7135551212 Didn't match with any of rules
router(config)#no voice translation-rule 6
router(config)#voice translation-rule 6
router(cfg-translation-rule)#rule 1 /^(7135551[2-4]..\)$/ /+\1/
% unmatched () ^
% Invalid input detected at '^' marker.
router(cfg-translation-rule)#rule 1 /^(7135551[2-4]..\$)/ /+\1/
router(cfg-translation-rule)#end
router#test voice translation-rule 6 7135551212
7135551212 Didn't match with any of rules
router(config)#voice translation-rule 6
router(cfg-translation-rule)#rule 1 /^1\(7135551[2-4]..\)$/ /+\1/
router(cfg-translation-rule)#end
router#test voice translation-rule 6 17135551212
Matched with rule 1
Original number: 17135551212 Translated number: +7135551212
Original number type: none Translated number type: none
Original number plan: none Translated number plan: none
Can anyone tell me why I'd be getting the results I'm getting? This is CME 8.5
Solved! Go to Solution.
11-09-2011 09:59 PM
For this rule
rule 1 /^(7135551[2-4]..)$/ /+\1/
And this test
test voice translation-rule 5 7135551212
You got
7135551212 Didn't match with any of rules
Because
Your test string of "7135551212" does not contain parenthesis "(" ")" as your pattern "/^(7135551[2-4]..)$/" is looking for.
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", which is how you group matches for recalling later
For this rule
rule 1 /^(7135551[2-4]..\)$/ /+\1/
You got
% unmatched ()
% Invalid input detected at '^' marker.
Because
You only escaped one of the parenthesis, therefore you have one literal "(" and one grouping "\)", neither of which have their required partner.
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", which is how you group matches for recalling later
For this rule
rule 1 /^(7135551[2-4]..\$)/ /+\1/
And this test
test voice translation-rule 6 7135551212
You got
7135551212 Didn't match with any of rules
Because
Your input string "7135551212" does not contain parenthesis "(" ")", nor a dollar sign "$", as your pattern "/^(7135551[2-4]..\$)/" is looking for
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", which is how you group matches for recalling later, and how you use the "end of line" special character "$"
For this rule
rule 1 /^1\(7135551[2-4]..\)$/ /+\1/
And this test
test voice translation-rule 6 17135551212
You got
Matched with rule 1
Original number: 17135551212 Translated number: +7135551212
Because
Your input string "17135551212" matches your pattern "/^1\(7135551[2-4]..\)$/" exactly, and the result was to write out a plus sign "+" followed by the match in group 1 "7135551212"
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", because it doesn't look like you actually needed to match on the leading "1"
If you simply wanted to prefix:
All numbers
rule 1 // /+/
Some numbers in a range
rule 1 /^7135551[2-4]..$/ /+\0/
A specific number
rule 1 /^7135551212$/ /+\0/
Note my use of the "\0" and the absence of parethesis grouping in the match pattern. This is a cleaner and more effecient way than grouping, and recalling "\1", because it happens automatically, and you create no additional overhead.
11-09-2011 05:11 PM
the second part of the rule is /+/
11-09-2011 09:59 PM
For this rule
rule 1 /^(7135551[2-4]..)$/ /+\1/
And this test
test voice translation-rule 5 7135551212
You got
7135551212 Didn't match with any of rules
Because
Your test string of "7135551212" does not contain parenthesis "(" ")" as your pattern "/^(7135551[2-4]..)$/" is looking for.
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", which is how you group matches for recalling later
For this rule
rule 1 /^(7135551[2-4]..\)$/ /+\1/
You got
% unmatched ()
% Invalid input detected at '^' marker.
Because
You only escaped one of the parenthesis, therefore you have one literal "(" and one grouping "\)", neither of which have their required partner.
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", which is how you group matches for recalling later
For this rule
rule 1 /^(7135551[2-4]..\$)/ /+\1/
And this test
test voice translation-rule 6 7135551212
You got
7135551212 Didn't match with any of rules
Because
Your input string "7135551212" does not contain parenthesis "(" ")", nor a dollar sign "$", as your pattern "/^(7135551[2-4]..\$)/" is looking for
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", which is how you group matches for recalling later, and how you use the "end of line" special character "$"
For this rule
rule 1 /^1\(7135551[2-4]..\)$/ /+\1/
And this test
test voice translation-rule 6 17135551212
You got
Matched with rule 1
Original number: 17135551212 Translated number: +7135551212
Because
Your input string "17135551212" matches your pattern "/^1\(7135551[2-4]..\)$/" exactly, and the result was to write out a plus sign "+" followed by the match in group 1 "7135551212"
To fix
Change your pattern to "/^\(7135551[2-4]..\)$/", because it doesn't look like you actually needed to match on the leading "1"
If you simply wanted to prefix:
All numbers
rule 1 // /+/
Some numbers in a range
rule 1 /^7135551[2-4]..$/ /+\0/
A specific number
rule 1 /^7135551212$/ /+\0/
Note my use of the "\0" and the absence of parethesis grouping in the match pattern. This is a cleaner and more effecient way than grouping, and recalling "\1", because it happens automatically, and you create no additional overhead.
11-10-2011 06:50 AM
You sir, rock!
Thanks
11-10-2011 11:26 AM
Thank you! And thanks for the rating! Good luck to you.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide