Has anybody already extended TRegExpr.Substitute to allow escape sequences other than '\c' -> 'c'? E.g. '\n' -> #10, '\r' -> #13 or '\xnn' => #$nn

Has anybody already extended TRegExpr.Substitute to allow escape sequences other than '\c' -> 'c'? E.g. '\n' -> #10, '\r' -> #13 or '\xnn' => #$nn

The original on https://github.com/masterandrey/TRegExpr apparently does not have that feature and it's difficult with all those copies on e.g. GitHub to find out how they actually differ. (Don't you love fragmentation?).
https://github.com/masterandrey/TRegExpr

Comments

  1. I found that freepascal has an extension to that unit that allows \n to be converted to the line feed string sequence (LF or CrLf), but for whatever reason doesn't go further and include \t and \xNN.

    ReplyDelete
  2. Converting \n to CrLf is a really odd implementation btw. It means that the regular expression is OS dependent which is not what I would expect. It only makes sense if \n also matches (only) CrLf rather than LF. Unless that's the case (which I haven't checked but assume to be so), replacing '\n' with '\n' would replace LF with CrLf which is definitely not what I would expect.

    ReplyDelete

Post a Comment