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
str = "What $noun$ is $verb$?" print str.replace("$noun$", "the heck")
Only use regular expressions when needed. It's generally slower.
1.4m articles
1.4m replys
5 comments
56.8k users