regex - How do I check if a string has exactly one of a certain character -


i'm trying scan strings see if have 1 of character.

for example if i'm looking question mark

hello? i'm here 

will match regex however

hello? listening? 

will not

i've tried ?{1} , ?{1}[^?]+ both don't work. can point me in right direction?

why not do:

(\?) 

and count number of matches.

or more simply, count number of ? in string using tr///

my $c = $string1 =~ tr/?//; 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -