Automation of config changes?

Below is the change config template I have created.

I need to change multiple switches, but I would like to further automate the process.

The config template below also gives the same details to all selected switches.

 

I would like to know how to use Orions Change template to extract both the snmp-server location and add quotes around it, so New-York City Hall becomes “New-York City Hall”.

 

More importantly I would like to know how I can extract only the numbers from the snmp-server contact and then take those numbers and add quotation marks at the beginning followed id- then closed with a quotation mark.

So Asset-1337 becomes “id-1337”.

 

Another issue is that some contact information could be spelt as ASSET, ASSSET, Assettt and so on and so forth.

 

It needs to go through each switch extract the necessary information then reformat it.

script BaseChangeTemplate

( NCM.Nodes @ContextNode, string @SearchString, string @Location)

{
string @Quote = '"'
string @ID = 'id-'
string @SysContact = @ContextNode.SysContact

int @length = strlength(@SysContact)+1
int @startindex = indexof(@SysContact, @SearchString)+1
int @substringlength = @length - @startindex
string @NewSysContact = substring(@SysContact, @startindex, @substringlength)

if (@startindex == 1)
CLI
{

}

else
CLI
{

}

CLI
{
snmp-server location @Quote+@Location+@Quote
write mem
}

CLI
{
snmp-server contact @Quote+@ID+@NewSysContact+@Quote
write mem
exit
}
}