I have a string: "y, i agree with u."
And I have array dictionary [(word_will_replace, [word_will_be_replaced])]:
[('yes', ['y', 'ya', 'ye']), ('you', ['u', 'yu'])]
i want to replace 'y' with 'yes' and 'u' with 'you' according to the array dictionary.
So the result i want: "yes, i agree with you."
I want to keep the punctuation there.
\bmeta character matches on word boundaries, as in, between a word and space or word and symbol. e.g.\by\bwill match ONLY the wordyon its own.{abc <-- ab, abcd <-- abc}. If you don't have this assumption, then only jamylak's solution is correct.