-1

My requirement is to replace empty spaces between strings which i mentioned below.The strings are seperated by |

String1=Location:New York|Enterprise:Apple Inc

Expected outcome String1=Location:NewYork|Enterprise:AppleInc What needs to be given inside the replace function as \s is considered as character s

coder_7
  • 47
  • 2
  • 9
  • 1
    So something like `myString.replace(/ /g, '');`? – MaartenDev Jun 23 '21 at 13:01
  • 5
    Does this answer your question? [Replace all whitespace characters](https://stackoverflow.com/questions/6507056/replace-all-whitespace-characters) – Beller Jun 23 '21 at 13:03
  • @Beller inside the bracket for the character to be replaced we should provide inside a quotes right? – coder_7 Jun 24 '21 at 03:29

1 Answers1

0

You can just use something like:

String1.replaceAll(' ', '');

Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll

MaartenDev
  • 5,631
  • 5
  • 21
  • 33
Welyngton Dal Prá
  • 758
  • 1
  • 10
  • 19
  • 1
    ReplaceAll function is not available in typescript.Replace is available but it replaces only the first instance – coder_7 Jun 24 '21 at 03:26