cut out part of a string

前端 未结 8 1577
北荒
北荒 2021-02-18 16:17

Say, I have a string

\"hello is it me you\'re looking for\"

I want to cut part of this string out and return the new string, something like

8条回答
  •  攒了一身酷
    2021-02-18 16:59

    You need to do something like the following:

    var s = "I am a string";
    
    var sSubstring = s.substring(2); // sSubstring now equals "am a string".
    

    You have two options about how to go about it:

    http://www.quirksmode.org/js/strings.html#substring

    http://www.quirksmode.org/js/strings.html#substr

提交回复
热议问题