Invalid regular expression error

前端 未结 4 762
清酒与你
清酒与你 2021-01-19 06:35


I\'m trying to retrieve the category part this string \"property_id=516&category=featured-properties\", so the result should be \"featured-properties\

4条回答
  •  隐瞒了意图╮
    2021-01-19 07:04

      var url = "property_id=516&category=featured-properties",
    
      urlRE = url.match(/(category=)([a-z-]+)/i); //don't forget i if you want to match also uppercase letters in category "property_id=516&category=Featured-Properties"
      //urlRE = url.match(/(?<=(category=))[a-z-]+/i); //this is a mess
    
      alert(urlRE[2]); 
    

提交回复
热议问题