I want to match the symbol @ inside a string. It doesn't matter if it is at the beginning, at the middle or at the end of string or anywhere inside it. What matters is to just match it only 0 or 1 times.
I thought of something like this:
^[^@]*@[^@]*$
But definitely doesn't work because even though it matches the symbol @ once, it can match it only inside the string.
@foobar Valid
foo@bar Valid
foobar@ Valid
fooba@r Valid
but
@@foobar Invalid
@foo@bar Invalid
foo@b@ar Invalid