I’m trying to extract strings from a text that features two different types of characters.
The characters are | and # and the text is coming from an outside source.
I will give you an example:
- Input:
#hello|#what|whatsup|should returnhello|andwhatsup. - Input:
#hello#should returnhello - Input:
|ola|1should returnola - Input:
|hello#|what#whatsup#nodeshould returnhello#andwhatsup
This works for your strings. I don’t know if I completely understood what you need, but I think it can be tuned if necessary:
Update:
I just read the middlerecursion example. Doesn’t work for that, I’m afraid, and I have to leave my computer for a while. So this is just something to get you started.
Update version that works for all the examples: