I would like to replace words in a string sentence such as:
What $noun$ is $verb$?
What's the regular expression to replace the characters in '$ $' (inclusive) with actual nouns/verbs?
You don't need a regular expression for that. I would do
string = "What $noun$ is $verb$?"
print string.replace("$noun$", "the heck")
Only use regular expressions when needed. It's generally slower.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With