Loading ...
Sorry, an error occurred while loading the content.

20703Re: regex to remove ties

Expand Messages
  • diodeom
    May 24, 2010
      Don <don@...> wrote:
      >
      <snip>
      >
      > It is possible that there may be more than one tie ...
      > I could have: 4T T and then 6T T T ... so ideas how to
      > solve this with regex?
      >

      Here's another take:

      :Loop
      ^!Find "(\d+)T(?:[^;]++; T)++" WRS
      ^!IfError End
      ^!Set %N%=^$GetReSubStrings$
      ^!Replace "^%N%T|; \KT" >> "^%N%" HARS
      ^!Goto Loop


      The pattern "(\d+)T(?:[^;]++; T)++" is meant to highlight all ties for a given place but only capture its digit(s). The subsequent replacement of any offending Ts is targeting this selection [H] before looping to locate (any) other group of ties.

      (\d+)T -- current place followed by a T; parentheses indicate here the only capturing substring, later referred to by ^$GetReSubStrings$
      ()++ -- followed by a max number of instances (of what's inside parentheses)
      ?: -- these signify a non-capturing substring
      [^;]++ -- max number of any characters (including newlines) that are NOT semicolon
      ; T -- which are preceding a mandatory semicolon/space/T combo
    • Show all 13 messages in this topic