Search code examples
htmlfacebookreplacespace

How to format string returned by facebook


I have shared an html div content to facebook along with a link to take users back to our website. The link is working fine as expected, but the string facebook is returning uses plus sign (+) as delimiter instead of space " ".

Can anyone help me on how to convert the plus(+) sign back to space " "?

This is a sample of the string facebook is returning.

.../oursiteurl/fb.php?title=Marriage%2FWedding+I+Thank+God+who+turned+the+tide+for+me+and+my+family

How can I remove those plus sign in that url. Thanks in advance


Solution

  • You can split the string based on + sign and join with space.

    const str = "Thank+God+who+turned+the+tide+for+me+and+my+family"
    
    const newStr = str.split("+").join(" ");
    console.log(newStr)