Re: Re: Regular Expressions?
| From: | CC Zona | Date: | Fri, 20 Apr 2001 18:19:07 +0000 |
| Subject: | Re: Re: Regular Expressions? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49593@lists.php.net to get a copy of this message | ||
In article <20010420055444.15906.qmail@rinjani.jetcoms.net>,
yanto@jetcoms.net ("yanto") wrote:
> (eregi("([0-9][a-z][A-Z]\.[0-9][a-z][A-Z]", $myArray[x]))
>
> and don't use character '^' in front of the pattern.
(Note that since the parentheses are unbalanced, the above will thorw a
parse error.)
Since it's eregi, you don't need both [a-z] and [A-Z]. And by putting the
digits and letters in separate character classes, the pattern can only
match strings with one digit followed by two letters, a dot, another digit,
and more more letters. IOW:
1ab.2Cd
3zY.9MX
(etc.)
Since the goal is to match like this...
> I want to match any of the following:
>
> 1.1 or a.a
>
> or 1111.1111 or aaaa.aaaa <-- any number of digits (0-9) or alpha (a-z)
> on either side of the dot.
...try something more like this..
eregi("[0-9a-z]+\.[0-9a-z]+", $myArray[x])
...which would match as shown in the samples, where a single matched
character on either side of the decimal is repeating. (change the plus
signs to asterisks if "any" number of letters/digits can include no
letters/digits.)
--
CC