Regex - global search

How to capture all values?

 Regex: /\{\S+\}/g  //


The /g isn't regex syntax. That's syntax that some languages use to control the construction/mode of the regex itself.

I tried to make as few changes as possible: Rust Playground

Note that you aren't using capturing groups here, so there is no reason to use captures.

1 Like

@BurntSushi thx for your reply. :wink:

I have a new problem. I would like to replace a {key} for value.
Keys and values are stored in HashMap.


The second example here should help: Regex in regex - Rust

Here's an updated playground: Regex in regex - Rust

@BurntSushi Incorrect link?

Ah whoops, here it is, thank goodness the playground saves the last program I type. :sweat_smile:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.