0

Could any wiz at regular expression write an expression that will check whether a string matches this format

number=string

must have the =sign included, the number can be anything up 3 numbers and the string can contain any characters

this would very much apreciated

i've been tryin this d*3/=/{aA-zZ}$/

thanks

2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by pritaeas
0

1-3 numbers, at least one character:

\d{1,3}=[a-zA-Z]+

If you'd want letters, digits and underscores, you can use:

\d{1,3}=\w+
0

if (preg_match("\d{1,3}=\w+", "123=hel_llo")) {
echo "A match was found.";
} else {
echo "A match was not found.";
}

i've written this code, and it brings up an error message? see below

'Delimiter must not be alphanumeric or backslash'

and how can i get it to work

0

You did not specify a delimiter:

preg_match("%\d{1,3}=\w+%", "123=hel_llo"))

Edited by pritaeas: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.