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?
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
Only use regular expressions when needed. It's generally slower.
Given that you are free to modify
$noun$
etc. to your liking, best practise to do this nowadays is probably to using theformat
function on a string: