mercredi 6 mai 2015

Powershell Regex Expression. Convert line uri to UK friendly format

I would like some assistance with Regex within Powershell please. If someone can help I'd be really grateful...

I have downloaded a script from Microsoft which will allow us to take a string and convert it into a friendly format to display on user profiles.

The original string is tel:+441234123456;ext=3456

What I need to do is convert it into a UK friendly format so

converted string is 01234 123456

The steps I think I need to take are :- Removing the tel:+44 and replacing with 0. After first 4 digits add a space. Finish the variable with the last 6 digits. Remove the ;ext=3456

There was a similar process but for US suggested, unfortunately no knowing regex this goes over my head slightly!

$tel = $LineURI -replace ‘tel:(\+1)([2-9]\d{2})([2-9]\d{2})(\d{4});ext=\d{4}’,’$1 ($2) $3-$4;

Any suggestions or help welcome!

Aucun commentaire:

Enregistrer un commentaire