Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

reactjs - How to substitute arguments in a regex pattern? (Javascript / React)

I have a simple regex pattern which I'm using to validate a string.

I want to use the same regex in order to produce a string, using the exact same regex.

For example, I have the following regex: const regex = ^action:(?<whatAction>(WRITE|READ|DELETE))$

Is there any function substitute so: substitute(regex, {whatAction: "WRITE"}) will yield action:WRITE?

Thanks in advance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...