Javascript正则表达式:如何在>之前删除字符串并包括>

Javascript正则表达式:如何在>之前删除字符串并包括>,javascript,regex,Javascript,Regex,我有一根这样的绳子 item[3]>something>another>more[1]>here hey>this>is>something>new . . . 我想为每一行所指示的每个迭代生成以下内容 item[3]>something>another>more[1]>here something>another>more[1]>here another>more[1]>here more[

我有一根这样的绳子

item[3]>something>another>more[1]>here
hey>this>is>something>new
.
.
.
我想为每一行所指示的每个迭代生成以下内容

item[3]>something>another>more[1]>here
something>another>more[1]>here
another>more[1]>here
more[1]>here
here
另一个例子:

hey>this>is>something>new
this>is>something>new
is>something>new
something>new
new

我想要一个正则表达式,或者以某种方式递增删除最左边的字符串,直到>

,以循环遍历这些案例,也许可以尝试以下方法:

while (str.match(/^[^>]*>/)) {
  str = str.replace(/^[^>]*>/, '');
  // use str
}

要遍历这些案例,请尝试以下方法:

while (str.match(/^[^>]*>/)) {
  str = str.replace(/^[^>]*>/, '');
  // use str
}
您可以使用以下方法进行操作:

另见:

您可以使用以下方法进行操作:

另见:

var str = 'item[3]>something>another>more[1]>here',
    delimiter = '>',
    tokens = str.split(delimiter); // ['item[3]', 'something', 'another', 'more[1]', 'here']

// now you can shift() from tokens
while (tokens.length)
{
    tokens.shift();
    alert(tokens.join(delimiter));
}