I agree with Marty's response.  I happen to be a visual learner, so if you
are too then below is a your example marked up with colors to highlight the
different parts of the rule.

(Also, read this:
http://www.cisco.com/en/US/tech/tk652/tk90/technologies_tech_note09186a0080325e8e.shtml
)


voice translation-rule 1
rule 1 /^\(*12*\)3\(*45*\)$/ /6\1\2/

 Set 1: *12*

Default set 0: 3

(note, if you have \0 in the replace string I'm not sure if that would
carry over the 3 or the full match set 12345 - it would be worth testing)
Set 2: *45*

router#test voice translation-rule 1 12345

Matched with rule 1
Original number: 12345 Translated number: 6*12**45*


Walking through this rule left to right...

1.   rule 1 /[match string]/ /[replace string]/

2.   your match string is 12345, with no digits before 1 or after 5, broken
up into 2 named "sets" as listed above in green (set 1) and blue (set 2).

3.   your replace string is 6\1\2.

4.   the 6 is a literal 6 and is the first digit of the translated number.

5.   next is "\1" - the "\" means the next character is special, so don't
use it literally (ie, it's not a "1" it is instead "set 1").  The match
string already defined set 1 as "*12*" by using the "\(" to to start the
set and "\)" to close the set.  You don't specify a number for the set -
working left to right the first set is "\1" second is "\2" and so on.  (If
you don't specify any sets using "\(" and "\)" then you still have a
default set 0 called as "\0" in the replace string which would be used to
insert the entire match string.)

6.   at this point your translated number is 6 *12* (plus the remaining
string).

7.   next and final part of the replace string is "\2" which means "set 2"

8.   in the replace string that means "put in the contents of set 2" or "*45
*".

9.   your translated number is 6*12**45*



*Further notes, if needed:*

·      The use of "^" means "starts with" so you only match a string *
starting* with 12345.

o   Input 12345 = MATCH, output is 61245

o   Input 012345 = NO match, output is unchanged 012345

·      The use of "$" means "ends with" so you won't match any additional
digits, and your string cannot contain any more digits.

o   Input 12345 = MATCH, output is 61245

o   Input 123456 = NO match, output is 123456

The combination of using ^ and $ in this case means only match literal
12345 with nothing before or after.  if you remove both ^ and $ you could
match 99912345000 and get the output 99961245000.

Hope this helps.  If it doesn't, read the link at the top :-)




On Fri, Oct 4, 2013 at 2:03 PM, Martin Sloan <martinsloa...@gmail.com>wrote:

> Hi Anthony,
>
> I'm not sure how to deep to go on the explanation but basically you have 2
> capture groups in the 'match' string which are denoted by the parentheses,
> which have to be escaped by the backslash.  These translations are based on
> the Unix Stream EDitor (SED) program and certain metacharaters need to be
> escaped to work properly, like the parentheses.  They're called capture
> groups because whatever is included between the parentheses will be
> 'captured' to a buffer. You can then refer to it in the 'replace' string by
> referencing it's capture group number, which also has to be escaped with a
> backslash, like '\1'.  In the *nix OS, you can create named capture groups
> so you can better identify the capture group and also insert new groups
> without having to update all others, but I don't believe this is possible
> in IOS.  The '6' in your replace string is a literal 6.
>
> HTH
> Marty
>
>
> On Fri, Oct 4, 2013 at 1:30 PM, Anthony Nwachukwu <anwachu...@apafrica.com
> > wrote:
>
>> I need with Translation -rule can someone help me explain the translation
>> rule below.
>>
>> voice translation-rule 1
>> rule 1 /^\(12\)3\(45\)$/ /6\1\2/
>> · Set 1: 12
>> · Set 2: 45
>> · Ignore: 3
>> router#test voice translation-rule 1 12345
>> Matched with rule 1
>> Original number: 12345 Translated number: 61245
>>
>> _______________________________________________
>> For more information regarding industry leading CCIE Lab training, please
>> visit www.ipexpert.com
>>
>> Are you a CCNP or CCIE and looking for a job? Check out
>> www.PlatinumPlacement.com
>>
>
>
> _______________________________________________
> For more information regarding industry leading CCIE Lab training, please
> visit www.ipexpert.com
>
> Are you a CCNP or CCIE and looking for a job? Check out
> www.PlatinumPlacement.com
>
_______________________________________________
For more information regarding industry leading CCIE Lab training, please visit 
www.ipexpert.com

Are you a CCNP or CCIE and looking for a job? Check out 
www.PlatinumPlacement.com

Reply via email to