DEV Community

Discussion on: Advanced splitting with Symbol.split

adamcoster profile image
Adam Coster

You can use String.prototype.split() for this purpose if you use a regex with capturing groups as the delimiter.

aminnairi profile image
Amin Author

Hi Adam and thanks for your reply.

You are absolutely right, it is possible to use a RegExp to achieve a similar result without having to use the Symbol.split.

The article is more focused on what the Symbol.split is, and one of its use-case.

If you ask me, I would be more confortable using something more explicit (maybe a third-party library full of splitters?) than using a RegExp (directly).

As a matter of fact, while writing this article, I didn't even knew there was a RegExp for that but the community is full of wonderful and clever people, including someone in the comment section that helped me enhance this article with a RegExp-based solution!

RegExp are still very obscur for most of us and using something explicit and declarative is for sure an added argument for using a splitter and this symbol.