Finding punctuation/quotation mark combos in strings

I am trying to find if a string has any of the following:
." (period followed by quotation mark)
," (comma followed by quotation mark)
!" (exclamation point followed by quotation mark)
?" (question mark followed by quotation mark)
+ (plus sign)

I am using this:

if myString:find(".\"") or myString:find(",\"") or myString:find("?\"") or myString:find("!\"") or myString:find("+") then  
 print("Found one")  
else  
 print ("Didn't find one")  
end  

The problem is that the if is coming back as true if any quotation mark is found in the string, not just ones preceded by a punctuation mark.

Is my code for finding that match wrong? [import]uid: 17827 topic_id: 34576 reply_id: 334576[/import]

I think you will need to escape the ‘.’, ‘?’, and ‘+’ with a backslash also, as they are special characters in regular expressions. You could try them each one at a time to verify. [import]uid: 22076 topic_id: 34576 reply_id: 137501[/import]

Ahh, I had not thought of that. Regular expressions are definitely not my thing.

Thanks, Carbondale.

I also found that I could just do myString:find("%p"") to get any punctuation followed by a quotation mark, which might just be easier to do if the speed is the same. [import]uid: 17827 topic_id: 34576 reply_id: 137533[/import]

I think you will need to escape the ‘.’, ‘?’, and ‘+’ with a backslash also, as they are special characters in regular expressions. You could try them each one at a time to verify. [import]uid: 22076 topic_id: 34576 reply_id: 137501[/import]

Ahh, I had not thought of that. Regular expressions are definitely not my thing.

Thanks, Carbondale.

I also found that I could just do myString:find("%p"") to get any punctuation followed by a quotation mark, which might just be easier to do if the speed is the same. [import]uid: 17827 topic_id: 34576 reply_id: 137533[/import]