🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to replace words based on keywords in the example

User: "sugaroo"
New Altair Community Member
Updated by Jocelyn
I wish to replace words in an example if ever it contains a keyword. In my case, any example that contains the word "street" must be replaced by "village". So if the example contains "Elmo street" then it will be replaced into "village" thanks!

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "kayman"
    New Altair Community Member
    You can use regex combined with the replace operator. 
    In this specific case it can be as simple as looking for street, and replacing it by village.

    Of course, this can be tricky if you have words that contain street, so you may need to use boundaries.

    For instance, using street\b means that street only should be replaced if it's at the end of a word (so followed by a space, a dot or whatever that's not a character)

    You can do this with a single word, or with a list of words. In the latter case ordering is very important to avoid unwanted replacements.