How to Search and replace a string in a string array

Chinmayee1
Giga Contributor

Hi,

I have a string such as

var str = "Hello Servicenow user Chinmayee Mishra.User user ID is : 1234s" ;

I have to find the ID and replace with another ID , lets say

var newStr = "Hello Servicenow user Chinmayee Mishra.Your user ID is : 987c";

The string  length is not constant as the names can be different.

 

How do I do it ? Please help.

Thanks & Regards,

Chinmayee Mishra