converting RegExp to String then back to RegExp

前端 未结 5 1920
忘了有多久
忘了有多久 2020-12-17 07:31

So I have a RegExp regex = /asd/

I am storing it as a as a key in my key-val store system.

So I say str = String(regex) which retur

5条回答
  •  旧巷少年郎
    2020-12-17 08:16

    let rx = RegExp.apply(RegExp, str.match(/\/(.*)\/(.*)/).slice(1));

    A modified version of @PegasusEpsilon answer

提交回复
热议问题