🎉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

Replace single characters without changing strings value of the attribute

User: "f_laperna"
New Altair Community Member
Updated by Jocelyn

Hi, I want to replace some values in an attribute of my dataset. In particular, I have some characters (like "C", "P", "A" and some strings, like "SPAIN", "ITALY" etc.).

I want to modify the value A without changing the string SPAIN. For example, by replacing A with "Other" I always obtain SPOtherIN.

I tried with A, with "A", with (A) but without success. Does anyone knows how to achieve that? Thank you!

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "Telcontar120"
    New Altair Community Member
    Accepted Answer

    Perhaps a more direct solution would be to use the lookaround syntax with regex.  Here's what you want, I think:

    (?<!\w)A(?!\w)

    This will only take "A" when it is not preceded by another word character before and after (thus it will skip "A" in the middle of a word).

    Try it and see if that works.

    But kudos to @FBT for a creative solution that would also work, albeit a more complex one.