Remove special characters from phone number .

Virendra Dwived
Tera Expert

Hi @Ankur Bawiskar 

I have requirement to remove special characters from Phone number . I have attached link below . 

Link - https://carear.app/#/s/dl.htm?serviceNow=true&id=WO0010026&name=Virendra%20Dwivedi&table_name=wm_order&table_sys_id=671e9e3c4792c110665a4e42846d436a&contact_mobile=(989)%20898-9898&contact_email=abel.jackson@mail.com&fqdn=ven04940.service-now.com&origin=https://ven04940.service-now.com/now/workspace/agent/record/wm_order/671e9e3c4792c110665a4e42846d436a&file_name=true

If you see the phone number part has brackets , % and hyphen . Is there a way to remove these special characters .

Thanks 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hey,

Why don't you try a simple function:

mystring='123 test 456 String 789 cleaning';

onlyNumeric=GlideStringUtil.getNumeric(mystring);

gs.info(onlyNumeric);

 

Output: 123456789

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

View solution in original post

3 REPLIES 3

Aman Kumar S
Kilo Patron

Hey,

Why don't you try a simple function:

mystring='123 test 456 String 789 cleaning';

onlyNumeric=GlideStringUtil.getNumeric(mystring);

gs.info(onlyNumeric);

 

Output: 123456789

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

Tudor
Tera Guru

Hi Virendra,

When parsing the URL you can use the following :

myString = myString.replace(/\D/g,'');

reference here

Hope this helps!
Tudor
 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what's your business requirement here?

where is this link present?

basically those special characters indicate something

%20 - means space

It helps in URL encoding and is required

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader