Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14626 > unrolled thread
| Started by | Eric <ekoome@yahoo.com> |
|---|---|
| First post | 2014-11-25 09:29 -0800 |
| Last post | 2014-11-30 20:21 +0100 |
| Articles | 14 — 6 participants |
Back to article view | Back to comp.lang.php
Regex to Match two letters Eric <ekoome@yahoo.com> - 2014-11-25 09:29 -0800
Re: Regex to Match two letters "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-25 19:08 +0100
Re: Regex to Match two letters Eric <ekoome@yahoo.com> - 2014-11-25 10:53 -0800
Re: Regex to Match two letters "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-25 20:07 +0100
Re: Regex to Match two letters Luuk <luuk@invalid.lan> - 2014-11-25 20:17 +0100
Re: Regex to Match two letters Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-11-25 14:17 -0500
Re: Regex to Match two letters "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-25 20:35 +0100
Re: Regex to Match two letters Eric <ekoome@yahoo.com> - 2014-11-25 12:55 -0800
Re: Regex to Match two letters Luuk <luuk@invalid.lan> - 2014-11-26 10:12 +0100
Re: Regex to Match two letters Eric <ekoome@yahoo.com> - 2014-11-26 01:46 -0800
Re: Regex to Match two letters Arno Welzel <usenet@arnowelzel.de> - 2014-11-30 07:21 +0100
Re: Regex to Match two letters Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-30 13:07 +0100
Re: Regex to Match two letters Arno Welzel <usenet@arnowelzel.de> - 2014-11-30 19:47 +0100
Re: Regex to Match two letters Luuk <luuk@invalid.lan> - 2014-11-30 20:21 +0100
| From | Eric <ekoome@yahoo.com> |
|---|---|
| Date | 2014-11-25 09:29 -0800 |
| Subject | Regex to Match two letters |
| Message-ID | <bd00054c-25fa-441a-a36a-56afa836cd12@googlegroups.com> |
Completely new to this but the following REGEX to match only two letters fails.
preg_match('/^[a-zA-Z]{2}$/','TZ');
This returns false.
[toc] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-11-25 19:08 +0100 |
| Message-ID | <m52gj4$g7f$1@solani.org> |
| In reply to | #14626 |
Eric wrote:
> Completely new to this but the following REGEX to match only two
> letters fails.
>
> preg_match('/^[a-zA-Z]{2}$/','TZ');
>
> This returns false.
No. It returns 1, see <http://3v4l.org/gvUmD>.
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Eric <ekoome@yahoo.com> |
|---|---|
| Date | 2014-11-25 10:53 -0800 |
| Message-ID | <3b5e6178-0da6-4db5-becd-348c8d548b88@googlegroups.com> |
| In reply to | #14626 |
On Tuesday, November 25, 2014 5:30:00 PM UTC, Eric wrote:
> Completely new to this but the following REGEX to match only two letters fails.
>
> preg_match('/^[a-zA-Z]{2}$/','TZ');
>
> This returns false.
This is returning false for me. Really strange. on php 5.4.16
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-11-25 20:07 +0100 |
| Message-ID | <m52k13$t0d$1@solani.org> |
| In reply to | #14628 |
Eric wrote:
> On Tuesday, November 25, 2014 5:30:00 PM UTC, Eric wrote:
>> Completely new to this but the following REGEX to match only two
>> letters fails.
>>
>> preg_match('/^[a-zA-Z]{2}$/','TZ');
>>
>> This returns false.
>
> This is returning false for me. Really strange. on php 5.4.16
Yes, that is really strange, because on <http://3v4l.org/n0lRc> it
returns 1 under PHP 5.4.16. Do you have a custom build or a
non-standard PCRE version?
Please try to avoid the broken Google Groups for posting to Usenet
newsgroups.
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2014-11-25 20:17 +0100 |
| Message-ID | <5474d5dd$0$2945$e4fe514c@news.xs4all.nl> |
| In reply to | #14628 |
On 25-11-2014 19:53, Eric wrote:
> On Tuesday, November 25, 2014 5:30:00 PM UTC, Eric wrote:
>> Completely new to this but the following REGEX to match only two letters fails.
>>
>> preg_match('/^[a-zA-Z]{2}$/','TZ');
>>
>> This returns false.
>
> This is returning false for me. Really strange. on php 5.4.16
>
even on windows, it returns 1
C:\WT-NMP\bin\php-5.4.35>php -r
"var_dump(preg_match('/^[a-zA-Z]{2}$/','TZ'));"
int(1)
C:\WT-NMP\bin\php-5.4.35>cd ..\php-5.5.19
C:\WT-NMP\bin\php-5.5.19>php -r
"var_dump(preg_match('/^[a-zA-Z]{2}$/','TZ'));"
int(1)
C:\WT-NMP\bin\php-5.5.19>cd ..\php-5.6.3
C:\WT-NMP\bin\php-5.6.3>php -r
"var_dump(preg_match('/^[a-zA-Z]{2}$/','TZ'));"
int(1)
[toc] | [prev] | [next] | [standalone]
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Date | 2014-11-25 14:17 -0500 |
| Message-ID | <AB4dw.784893$FX2.447824@fx18.iad> |
| In reply to | #14628 |
On Tuesday 25 November 2014 13:53, in comp.lang.php, "Eric"
<ekoome@yahoo.com> wrote:
> On Tuesday, November 25, 2014 5:30:00 PM UTC, Eric wrote:
>> Completely new to this but the following REGEX to match only two letters
>> fails.
>>
>> preg_match('/^[a-zA-Z]{2}$/','TZ');
>>
>> This returns false.
>
> This is returning false for me. Really strange. on php 5.4.16
This returns 1 for me on PHP 5.4.32 with PCRE library vers 8.12 2011-01-15
<?php
echo 'preg_match() returned';
switch($a = preg_match('/^[a-zA-Z]{2}$/','TZ'))
{
case 0: echo ' zero';
break;
case 1: echo ' one';
break;
case false: echo ' false';
break;
default: echo $a ;
break;
}
?>
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-11-25 20:35 +0100 |
| Message-ID | <m52lm5$3f4$1@solani.org> |
| In reply to | #14631 |
Lew Pitcher wrote:
> This returns 1 for me on PHP 5.4.32 with PCRE library vers 8.12 2011-01-15
>
> <?php
> echo 'preg_match() returned';
> switch($a = preg_match('/^[a-zA-Z]{2}$/','TZ'))
> {
> case 0: echo ' zero';
> break;
>
> case 1: echo ' one';
> break;
>
> case false: echo ' false';
> break;
>
> default: echo $a ;
> break;
> }
> ?>
Note, however, that switch/case does loose comparison. E.g.:
switch (false) {
case 0: echo 'zero'; break;
default: echo 'non-zero'; break;
}
prints
zero
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Eric <ekoome@yahoo.com> |
|---|---|
| Date | 2014-11-25 12:55 -0800 |
| Message-ID | <73a4614d-a97e-4303-b135-e6c21242f18b@googlegroups.com> |
| In reply to | #14632 |
My ios logitech keyboard was giving the wrong ^ character. Fixed.
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2014-11-26 10:12 +0100 |
| Message-ID | <54759983$0$2890$e4fe514c@news.xs4all.nl> |
| In reply to | #14633 |
On 25-11-2014 21:55, Eric wrote:
> My ios logitech keyboard was giving the wrong ^ character. Fixed.
>
Is there more than one '^' character?
luuk@opensuse:~> php -r ' print ord("^")."\n"; '
94
what is the output of this 'wrong ^ character'?
(just curious ;)
[toc] | [prev] | [next] | [standalone]
| From | Eric <ekoome@yahoo.com> |
|---|---|
| Date | 2014-11-26 01:46 -0800 |
| Message-ID | <3ab8731d-a931-4ca2-836b-c7532be10995@googlegroups.com> |
| In reply to | #14635 |
On Wednesday, November 26, 2014 9:13:00 AM UTC, Luuk wrote:
> On 25-11-2014 21:55, Eric wrote:
> > My ios logitech keyboard was giving the wrong ^ character. Fixed.
> >
>
> Is there more than one '^' character?
>
> luuk@opensuse:~> php -r ' print ord("^")."\n"; '
> 94
>
> what is the output of this 'wrong ^ character'?
>
> (just curious ;)
Complains of undefined constant
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2014-11-30 07:21 +0100 |
| Message-ID | <547AB787.8070500@arnowelzel.de> |
| In reply to | #14635 |
Luuk schrieb am 2014-11-26 um 10:12:
> On 25-11-2014 21:55, Eric wrote:
>> My ios logitech keyboard was giving the wrong ^ character. Fixed.
>>
>
> Is there more than one '^' character?
>
> luuk@opensuse:~> php -r ' print ord("^")."\n"; '
> 94
>
> what is the output of this 'wrong ^ character'?
>
> (just curious ;)
Probably one of these:
˄ (˄)
ˆ (ˆ)
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-11-30 13:07 +0100 |
| Message-ID | <1580091.fUpjlrXKjt@PointedEars.de> |
| In reply to | #14671 |
Arno Welzel wrote:
> Luuk schrieb am 2014-11-26 um 10:12:
>> On 25-11-2014 21:55, Eric wrote:
>>> My ios logitech keyboard was giving the wrong ^ character. Fixed.
>>
>> Is there more than one '^' character?
>>
>> luuk@opensuse:~> php -r ' print ord("^")."\n"; '
>> 94
>>
>> what is the output of this 'wrong ^ character'?
>>
>> (just curious ;)
>
> Probably one of these:
>
> ˄ (˄)
> ˆ (ˆ)
^^^^^^^^
ord() could not return that as it returns the code point value while
recognizing only up to 8 bit per character (it returns nonsense beyond
0xFF); but mb_encode_numericentity() could.
Indeed, it is much easier to type a (standalone) Unicode combining mark with
a Macintosh keyboard layout. This may be either the cause or the effect of
Mac OS using the combining form of Unicode characters by default, pointing
out the importance of Unicode character normalization.
--
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2014-11-30 19:47 +0100 |
| Message-ID | <547B6649.5030500@arnowelzel.de> |
| In reply to | #14672 |
Thomas 'PointedEars' Lahn schrieb am 2014-11-30 um 13:07:
> Arno Welzel wrote:
>
>> Luuk schrieb am 2014-11-26 um 10:12:
>>> On 25-11-2014 21:55, Eric wrote:
>>>> My ios logitech keyboard was giving the wrong ^ character. Fixed.
>>>
>>> Is there more than one '^' character?
>>>
>>> luuk@opensuse:~> php -r ' print ord("^")."\n"; '
>>> 94
>>>
>>> what is the output of this 'wrong ^ character'?
>>>
>>> (just curious ;)
>>
>> Probably one of these:
>>
>> ˄ (˄)
>> ˆ (ˆ)
> ^^^^^^^^
> ord() could not return that as it returns the code point value while
> recognizing only up to 8 bit per character (it returns nonsense beyond
> 0xFF); but mb_encode_numericentity() could.
Of course you're right - I just mentioned those characters to show that
there is indeed somthing looking similar to the ^ character, just to
satisfy couriosity ;-)
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2014-11-30 20:21 +0100 |
| Message-ID | <547b6e2b$0$2886$e4fe514c@news.xs4all.nl> |
| In reply to | #14673 |
On 30-11-2014 19:47, Arno Welzel wrote:
> Thomas 'PointedEars' Lahn schrieb am 2014-11-30 um 13:07:
>> Arno Welzel wrote:
>>
>>> Luuk schrieb am 2014-11-26 um 10:12:
>>>> On 25-11-2014 21:55, Eric wrote:
>>>>> My ios logitech keyboard was giving the wrong ^ character. Fixed.
>>>>
>>>> Is there more than one '^' character?
>>>>
>>>> luuk@opensuse:~> php -r ' print ord("^")."\n"; '
>>>> 94
>>>>
>>>> what is the output of this 'wrong ^ character'?
>>>>
>>>> (just curious ;)
>>>
>>> Probably one of these:
>>>
>>> ˄ (˄)
>>> ˆ (ˆ)
>> ^^^^^^^^
>> ord() could not return that as it returns the code point value while
>> recognizing only up to 8 bit per character (it returns nonsense beyond
>> 0xFF); but mb_encode_numericentity() could.
>
> Of course you're right - I just mentioned those characters to show that
> there is indeed somthing looking similar to the ^ character, just to
> satisfy couriosity ;-)
>
>
curiosity satisfied,
thanks
;)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web