Bitcoin Forum
December 11, 2016, 08:20:54 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: PHP preg_match not working?  (Read 1634 times)
Inedible
Hero Member
*****
Offline Offline

Activity: 630


What doesn't kill you only makes you sicker!


View Profile
August 11, 2011, 08:34:36 PM
 #1

I was going to put this in the Development section but I decided it was too small a fragment to be directly relevant to Bitcoin so I figured I'd post here instead.

I'm trying to get a unicode regular expression working but I think it might not be working properly.

Currently I'm testing with:

Code:
<?php

$pattern 
'/[\p{L}]*$/';
$check preg_match($pattern'Testing èggs');

if (
$check) {
echo 'matched';
} else {
echo 'no match';
}

?>


This matches fine but as soon as I change the $pattern to:

Code:
$pattern = '/^[\p{L}]*$/'

It stops working.

My understanding is that the ^ at the start of the pattern means to search from the start.

If so, why does it stop working? It works so long as it's not multi language, e.g. using the \w shorthand.

Is my understanding wrong or is this not working on my PC?

If this post was useful, interesting or entertaining, then you've misunderstood. 1N6rmaDiPf8ke3mx8217NykAMDZXkX713x
1481444454
Hero Member
*
Offline Offline

Posts: 1481444454

View Profile Personal Message (Offline)

Ignore
1481444454
Reply with quote  #2

1481444454
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481444454
Hero Member
*
Offline Offline

Posts: 1481444454

View Profile Personal Message (Offline)

Ignore
1481444454
Reply with quote  #2

1481444454
Report to moderator
1481444454
Hero Member
*
Offline Offline

Posts: 1481444454

View Profile Personal Message (Offline)

Ignore
1481444454
Reply with quote  #2

1481444454
Report to moderator
1481444454
Hero Member
*
Offline Offline

Posts: 1481444454

View Profile Personal Message (Offline)

Ignore
1481444454
Reply with quote  #2

1481444454
Report to moderator
Bitsky
Hero Member
*****
Offline Offline

Activity: 542


View Profile
August 11, 2011, 10:26:39 PM
 #2

Because the è isn't at the start of the line. Try the haystack 'èggs' and it will match.

Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!