regex - get numbers after certain character string

前端 未结 3 1233
执念已碎
执念已碎 2020-12-16 01:24

I have a text string that can be any number of characters that I would like to attach an order number to the end. Then I can pluck off the order number when I need to use it

3条回答
  •  青春惊慌失措
    2020-12-16 02:04

    I see no need for regex for this:

    var str="aijfoi aodsifj adofija afdoiajd?order_num=3216545";
    var n=str.split("?");
    

    n will then be an array, where index 0 is before the ? and index 1 is after.

    Another example:

    var str="aijfoi aodsifj adofija afdoiajd?order_num=3216545";
    var n=str.split("?order_num=");
    

    Will give you the result: n[0] = aijfoi aodsifj adofija afdoiajd and n[1] = 3216545

提交回复
热议问题