Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18480

Re: preg_match() return false

Path csiph.com!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!3.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.php
Subject Re: preg_match() return false
Date Sun, 27 Dec 2020 15:33:01 +0000
Organization A noiseless patient Spider
Lines 35
Message-ID <87im8n9scy.fsf@bsb.me.uk> (permalink)
References <rs9s7j$1vsr$1@gioia.aioe.org>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
Injection-Info reader02.eternal-september.org; posting-host="fa0a8e29de1fb8d8b5558f843341d433"; logging-data="9274"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fzrwuFJbi4Z/GwnKaDLTad+S5qRlIrPQ="
Cancel-Lock sha1:jzROExBLCs57m9soDjnh6lCO2xk= sha1:ocxDt7q1siBc5sYhuslU+DX7iDo=
X-BSB-Auth 1.a1d166529cdb3a09abad.20201227153301GMT.87im8n9scy.fsf@bsb.me.uk
Xref csiph.com comp.lang.php:18480

Show key headers only | View raw


alex <1j9448a02@lnx159sneakemail.com.invalid> writes:

> $regex = file_get_contents(
>     // Download URç: https://files.fm/f/9mwzkn2wr
>     'data/regex'
> );
> $subject = file_get_contents(
>     // Download URL: https://files.fm/f/8xeaybz5z
>     'data/subject'
> );
>
> $matching = preg_match($regex, $subject);
>
> if (0 === $matching) {
>     echo "Matching is 0";
> } elseif (FALSE === $matching) {
>     echo "Matching is FALSE";
> } else {
>     echo "OK!!!";
> }
>
> Output:
>
> Matching is FALSE
>
> Why?

I don't know, but your regexp is odd.  If you delete the second line it
matches.  You don't need to .+¶ after matching .+¶ because the s
modifier means the first will match to the same place the second would.

Also, you don't need \ before - or :.

-- 
Ben.

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

preg_match() return false alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-27 12:47 +0100
  Re: preg_match() return false tony@mountifield.org (Tony Mountifield) - 2020-12-27 12:50 +0000
    Re: preg_match() return false alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-27 14:21 +0100
  Re: preg_match() return false Arno Welzel <usenet@arnowelzel.de> - 2020-12-27 14:43 +0100
    Re: preg_match() return false alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-27 14:59 +0100
      Re: preg_match() return false Arno Welzel <usenet@arnowelzel.de> - 2020-12-28 15:16 +0100
    Re: preg_match() return false alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-27 15:11 +0100
  Re: preg_match() return false Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-12-27 15:33 +0000
    Re: preg_match() return false alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-27 16:50 +0100
      Re: preg_match() return false alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-27 17:14 +0100
        Re: preg_match() return false Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-12-28 02:02 +0000
          Re: preg_match() return false alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-28 10:38 +0100
          Re: PHP_EOL (was: preg_match() return false) "J.O. Aho" <user@example.net> - 2020-12-28 15:43 +0100
            Re: PHP_EOL alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-12-29 15:55 +0100

csiph-web