I am trying to format a MAC address in a table that is populated using AngularJS:
<tr ng-repeat="dev in devices">
<td>{{dev.mac.replace(/(.{2})/g,"$1:")}}</td>
</tr>
{{dev.mac}} works just fine (aside from being unformatted), but when I add the .replace() function it breaks. I tried escaping the forward slash based on the error I received, which didn't help. Is .replace() not available inside the browser or is there a different syntax for regex inside the double braces or what am I doing wrong?
The goal is to convert AABBCCDDEEFF into AA:BB:CC:DD:EE:FF as easily as possible within the double braces. As a bonus question, how do I prevent the trailing ':' in the regex (it currently prints AA:BB:CC:DD:EE:FF:)?
Edit: Adding the error message
Error: $parse:syntax Syntax Error
Syntax Error: Token '/' not a primary expression at column 20 of the expression [dev.mac.replace(/(.{2})/g,"$&:")] starting at [/(.{2})/g,"$&:"].
That seems to indicate the forward slash is causing the problem, but like I said, escaping it doesn't help.
<td>{{dev.mac.replace(/../g,"$&:")}}</td>