Regex - What once worked now does not. I think.



  • I’m doing a simple find and replace. I had it working, now it doesn’t work.

    Have I made a mistake? It’s so simple:

    [(A-Z)\.][(A-Z)]

    Or maybe:
    [(A-Z)(\.)][(A-Z)]

    It should find instances of any uppercase alpha character, followed by a “.”, followed by another uppercase alpha character.

    And it worked in the past!

    I do it today and it is ALSO finding any instance of two uppercase alpha characters in a row.

    What have I forgotten here?

    Thanks guys.



  • OK my time to edit a post is gone so I have to correct the above in a new post:

    I do it today and it is finding any instance of two uppercase alpha characters in a row, and any instance of a “.” followed by an uppercase alpha character.

    Instead of finding “A.B” and NOT “AB”, it is finding “AB” and “.B” and NEVER “A.B”.



  • Wait… now if I look at my search history it gives me:
    ([A-Z].)([A-Z])

    I’m an idiot.



  • @Skullmonger said in Regex - What once worked now does not. I think.:

    I’m an idiot.

    And since you didn’t put your regex inside backticks when posting, so that it looks like this (the formatting): see how I'm in red
    We really don’t have a lot of confidence in what you’ve said in order to be able to help you (if you still need help, which is unclear).



  • Maybe that’s it?
    [A-Z]\.[A-Z]


Log in to reply