To be more prescise use this
Convert this
Xyz subject ab&‘#ab test
“contains (subject ‘ab&’ #ab’)”
To This
Xyz subject ab&%26%60%23ab test
“contains (subject ‘ab%26%60%23ab’)”
Please let me know if you face any issue else please mark solution to help others
Cheers