Mohammed Farooq Mohammed Farooq - 1 year ago 95
Javascript Question

javascript regex to remove particular format text from string

I have a dynamic string and I want to remove particular format text from String. (i.e *Number)

For example:

/1*Region 1/42*Europe/51*Test/100*New Folder/119*New Folder

Output :
/Region 1/Europe/Test/New Folder/New Folder

Thanks in advance.

Answer Source

var str = "/1*Region 1/42*Europe/51*Test/100*New Folder/119*New Folder";

var regex = /(\/\d+\*)/g;

var output = str.replace( regex, '/' );

console.log( output );

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download