How to get text between two characters?

后端 未结 6 1133
难免孤独
难免孤独 2020-12-06 04:55

|text to get| Other text.... migh have \"|\"\'s ...

How can I get the text to get stuff from the string (and remove it)?

It should

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 05:13

    var test_str = "|text to get| Other text.... migh have \"|\"'s ...";
    var start_pos = test_str.indexOf('|') + 1;
    var end_pos = test_str.indexOf('|',start_pos);
    var text_to_get = test_str.substring(start_pos,end_pos)
    alert(text_to_get);
    

提交回复
热议问题