I wanted to validate a string with preg_match but after a lot of struggle I just used if($str[0]!='x'....
but just out of curiosity I wonna know how to do this using preg_match
I'm getting a string as an input-
the 1st char in the string must be %
the 2nd char must be space
the 3rd char must be a number
and the rest can be anything (special chars/numbers/letters..)
arcticM
Recommended Answers
Jump to PostSomething like this should work.
The
/
at the beginning and end of the pattern are delimiters.
The^
denotes the start of the line or string.
The$
denotes the end of the line or string. Thus everything between the^
and$
must …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.