<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-2">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p> <span> </span></p>
<div style="-en-clipboard:true;">hi,</div>
<div style="-en-clipboard:true;"><br>
</div>
<div style="-en-clipboard:true;">If you are using JavaScript for
*AGI/ARI/AMI we made small library for asterisk dialplan pattern
matching and number manipulation</div>
<div><a
href="https://www.npmjs.com/package/asterisk-pattern-matching"
moz-do-not-send="true">https://www.npmjs.com/package/asterisk-pattern-matching</a></div>
<div><br>
</div>
<div><br>
</div>
<div>examples</div>
<div><br>
</div>
<div><br>
</div>
<div>const { validateNumber } = require("asterisk-pattern-matching")</div>
<div>// list of examples, return true or false</div>
<div>validateNumber('_X.', 123456789) // true</div>
<div>validateNumber('_[+0-9].', 123456789) // true</div>
<div>validateNumber('_X.', '+123456789') // false</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>// function to verify the asterisk pattern truth and parse
number by given settings<br>
const { parseNumber } = require("asterisk-pattern-matching")<br>
<br>
// list of examples, function ends at first pattern match<br>
const myPatterns = [<br>
/*<br>
{<br>
pattern:, // (String) asterisk pattern<br>
deleteFromStart:, // (String|Number) indicates, how many
chars should be removed from number's START<br>
deleteFromEnd:, // (String|Number)indicates, how many
chars should be removed from number's END <br>
prefix:, // (String|Number) indicates, what should be
added to number's START<br>
suffix: // (String|Number) indicates, what should be
added to number's END <br>
},<br>
*/<br>
{<br>
pattern: '_77X.',<br>
deleteFromStart: 1,<br>
deleteFromEnd: 1,<br>
prefix: '***', <br>
suffix: '###'<br>
},<br>
{<br>
pattern: '_[*#0-9].',<br>
deleteFromStart: '2',<br>
deleteFromEnd: '1',<br>
prefix: 123,<br>
suffix: 321<br>
},<br>
{<br>
pattern: '_+X.',<br>
deleteFromStart: 4, <br>
deleteFromEnd: 3, <br>
prefix: '0', <br>
suffix: '123'<br>
}<br>
]<br>
<br>
// [] = removed, () = added<br>
// second pattern (_[*#0-9].) from variable myPatterns is valid,
<br>
// (123)[+4]20999888-7[7](321) => result 12320999888-7321<br>
// function stops after first valid pattern<br>
parseNumber('*420999888-77', myPatterns)<br>
<br>
<br>
// last pattern (_+X) from variable myPatterns is valid, <br>
// (9)[+420]999888[-77](123) => result 0999888123<br>
parseNumber('+420999888-77', myPatterns)<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Marek Cervenka<br>
</div>
</body>
</html>