I’m trying to write a regular expression that will match a variable length string, remove certain text. Here are some examples of trying to achieve:
Equipment Changes: 2 - Mon Rose - Blinkers On;7 - Queen's Harbor - Blinkers On
Would yield
2 - Mon Rose - Blinkers On;7 - Queen's Harbor - Blinkers On
The example above includes 2 equipment changes, however, there could be 1 to 12 equipment changes. I’m hoping that one regular expression can handle all circumstances. The horse names will always vary as will the type of equipment changes (Blinkers On, Blinkers Off, Bar Shoe, etc)
I can match one, but I’m having difficulty with the variable requirement.
My code for matching one equipment change follows:
(Equipment Changes:)\s[\dA-Z]{1,2}\s-\s[A-Za-z\d]{1,18}\s-\s[A-Z]\s?[a-z]+\s[A-Za-z]+\s?[A-Za-z]
This matches one equipment change.I was hoping to be able to + or {1,12} to make it handle multiple changes.
Any help would be appreciated.
Thanks
If you are not trying to separate the equipment changes, this should work. (Passes everything until the colon then takes the rest of the string.)
And if you are trying to separate them you can split using the semicolon. (Passes everything until the colon then takes pieces of the string separated by semicolon and the last piece ends when the string ends.)