I am struggling to modify captured value with regex.
For example, I wanna change "Hello, he is hero"
to "HEllo, HE is HEro"
using Regex.
I know there are ways to change this without regex, but it is just an example to show the problem. I actually use the regex instead of just he
, but I cannot provide it here. That is why using regex is required.
The code below somehow does not work. Are there any ways to make it work?
"Hello, he is hero".replacingOccurrences(
of: #"(he)"#,
with: "$1".uppercased(), // <- uppercased is not applied
options: .regularExpression
)