ID:2102239
 
Code:
    var/regex/endPunc = new("\\.|!|\\?|\"|\\)|]|'|>")
if(!endPunc.Find(message, length(message)))
message += "."


Problem description:

Ok, I'm trying to check message for any punctuation at the end, and if there isn't and put a . on
The code above is putting the . on if there isn't any, but is removing the punctuation if it is found which obviously isn't desirable.

I'm guessing it's a mistake in the pattern, but I can't figure it out. Any help much appreciated


I would switch this to use a character class. I don't see a problem with the pattern, except that for extra safety you could stick another \\ in before the \" so it becomes \" in the actual pattern. But IMO you'd be better off with "[\.!\?\\\"'\\>\]]" as the pattern.

However I don't see anything in that code that would account for removing the punctuation. Can you show me more of that proc (or verb)? Find() should under no circumstances alter the original text.
Thanks Lummox JR. Yeah, my bad, the problem was actually with a replacetext() later on.

Thanks for the improvement in the pattern though
You can't actually escape things in character classes (even ']'; it just must be the first character, and empty character classes are invalid ie '[]]' is a character class containing only ']'), so the regex you'd want is actually [].!?\"'>], or "\[].!?\\\"'>]" as a string.