Rust regex pattern - unrecognized escape pattern

前端 未结 3 811
醉话见心
醉话见心 2021-01-21 07:25

I do have following string:

\\\"lengthSeconds\\\":\\\"2664\\\"

which I would like to match with this regexp:

Regex::new(\"lengt         


        
3条回答
  •  旧时难觅i
    2021-01-21 07:54

    You only need to escape the \ in the regex and can then use a raw string.

    r#"\\"lengthSeconds\\":\\"2664\\""# is a valid regex which matches \"lengthSeconds\":\"2664\"

    Playground

提交回复
热议问题