2021年3月7日星期日

Split a string at the first occurence of a string using Javascript

I've tried multiple solutions from other threads but nothing seems to work when the split flag is a string as well. In this case I need to separate the first " - " (space dash space) from the rest of the string, which contains other occurences of " - "

var string = "1 - 000 : 3 - loremipsum";

Looking for a resulting array of:

[1][000 : 3 - loremipsum]

https://stackoverflow.com/questions/66523787/split-a-string-at-the-first-occurence-of-a-string-using-javascript March 08, 2021 at 10:58AM

没有评论:

发表评论