Hello, I'm in the process of updating a program that fixes subtitles.
Till now I got away without using regular expressions, but the last problem that has come up might benefit by their use. (I've already solved it without regular expressions, but it's a very unoptimized method that slows my program significantly).
TL;DR;
I'm trying to make the following work:
I want all instances of:
"! ."
, "!."
and "! . "
to become: "!"
unless the dot is followed by another dot, in which case I want all instances of:
"!.."
, "! .."
, "! . . "
and "!. ."
to become: "!..."
I've tried this code:
the_str = Regex.Replace(the_str, "\\! \\. [^.]", "\\! [^.]");
that comes close to the first part of what I want to do, but I can't make the [^.]
character of the replacement string to be the same character as the one in the original string... Please help!
I'm interested in both C# and PHP implementations...