I want to check a certain pattern in a string. My pattern contains 3 parts:
- Start : First character should be a number or alphabet
- End : Last character should be a number or alphabet
- Middle : In between characters can be any combination of numbers, alphabets or a hyphen/minus(-) or @.
I am using following regex:
preg_match('/^[a-zA-Z0-9]+[@\-]*[a-zA-Z0-9]+$/i');
and tested on string :
a-121kabrastreet@90
which evaluates to false. Please rectify my logic. Thank you
/a-zA-Z/i- it must be ignore-case-twice day. I see three conditions in your "text requirements, and three repetitions in your pattern. Please put "the middle repeated pattern"[@\-]*in words. How is the string "aa" matched, how "aaa"?