What I have is a program that takes user’s input from a textbox and adds a period to the end of it. The problem I’m trying to solve is if the user puts a period at the end of what they have typed then I want to be able to remove that period. I tried to use the string replace method but that only lets you do it for a single character. The next thing I thought about was regular expressions.
I tried this:
finalString = Regex.Replace(finalString, "..", ".");
but all it did was replace every character with a period. Is there a regular expression that would let me replace 2 periods that are next to each other?
.has a special meaning so you need to escape it with\or simply use verbatim symbol
adding
$at the end of the regex asserts if the position of the period is on the last part of the string.