News for hackers. Stuff that matters.
Re:Rust is for Professionals by hardwaregeek on Tuesday April 13, 2021 @12:07PM (#26794365)
I don't know if this helpful, but from your description of your problem, here's how I'd do that in Rust:

- Use a regex to find a string in some text: use regexes, get a &str

- Escape all the regex reserved characters in that string: Okay this requires mutation but we can't mutate a &str, let's loop over the &str's characters (using the Chars iterator) and push them into a new String with the proper escapes

- The new String we own, so we can easily turn it into a regex and use it to search the original string.

There are no comments on this comment yet.