Search code examples
stringsplitescapingdelimiter

I have a string which contains delimeter as ^ and string as my^name^he^llo^qwerty, I want to split the string and avoid delimeters in some cases


I have a string which contains delimeter as ^ and string as my^name^he^llo^qwerty, i want to split the string but using delimeter as ^ giving me output as,

my name he llo qwerty

But i need my return strings as my name he^llo qwerty

Please suggest if we can split the string in this fashion avoiding that delimeter in some cases.


Solution

  • Decided to use the delimiter specifically different which will not be used in Strings, As there is no simple way to achieve the splitting of string in some cases and avoid it in some cases.