Replacing words with my own abbreviations in a list of fixtures



  • Hello.
    I run a football forum and would like to replace some football club names with abbreviated names of my choice.
    For example, here is a typical list of fixtures which I might paste into Notepad ++
    Manchester United v Nottingham Forest
    Queens Park Rangers v Newcastle United
    Sheffield Wednesday v Sheffield United
    Manchester City v Milton Keynes Dons

    I want to change the fixtures to this:
    Man Utd v Nottm Forest
    QPR v Newcastle
    Sheff Wed v Sheff Utd
    Man City v MK Dons

    Thank you.



  • @Gary-Barnes

    I assume you do not want to do 8 single replaces therefore
    I recommend using regular expressions and a technique
    as described by @guy038 here.

    Cheers
    Claudia



  • Dear Claudia,
    thank you for your help. Unfortunately, I do not understand the explanation described by guy038.
    I was hoping I could enter words in the find box, like Manchester United, Sheffield Wednesday, etc, and in the replace box, Man Utd, Sheff Wed, etc.
    I wrongly believed that the words entered in the find box and then in the replace box could be separated by a common symbol, like a comma or forward slash.
    If you or another member would be kind enough to show me exactly how to enter the information in the find and replace boxes using football teams as described in my first post, I will be extremely grateful.

    Thank you.



  • @Gary-Barnes

    No, you cannot just provide a list. You need to use regex. I did it for 3 teams, I guess you can add
    the rest yourself.

    Find what:(?-i)\b(?:(Manchester United)|(Nottingham Forest)|(Queens Park Rangers))\b
    Replace with:(?1Man Utd)(?2Nottm Forest)(?3QPR)
    

    more info about regex: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

    Cheers
    Claudia



  • Thank you so much!


Log in to reply