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


Groups > comp.lang.php > #18474 > unrolled thread

preg_match() return false

Started byalex <1j9448a02@lnx159sneakemail.com.invalid>
First post2020-12-27 12:47 +0100
Last post2020-12-29 15:55 +0100
Articles 14 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  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

#18474 — preg_match() return false

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-27 12:47 +0100
Subjectpreg_match() return false
Message-ID<rs9s7j$1vsr$1@gioia.aioe.org>
$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?

[toc] | [next] | [standalone]


#18475

Fromtony@mountifield.org (Tony Mountifield)
Date2020-12-27 12:50 +0000
Message-ID<rs9vut$dtu$1@softins.softins.co.uk>
In reply to#18474
In article <rs9s7j$1vsr$1@gioia.aioe.org>,
alex  <1j9448a02@lnx159sneakemail.com.invalid> wrote:
> $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?


Does your regex string include the delimiters? It needs to.

Cheers
Tony
-- 
Tony Mountifield
Work: tony@softins.co.uk - http://www.softins.co.uk
Play: tony@mountifield.org - http://tony.mountifield.org

[toc] | [prev] | [next] | [standalone]


#18476

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-27 14:21 +0100
Message-ID<rsa1pc$d86$1@gioia.aioe.org>
In reply to#18475
Il 27/12/20 13:50, Tony Mountifield ha scritto:
> Does your regex string include the delimiters? It needs to.

In my code there are also two http urls.
Haven't you noticed them?

[toc] | [prev] | [next] | [standalone]


#18477

FromArno Welzel <usenet@arnowelzel.de>
Date2020-12-27 14:43 +0100
Message-ID<i4rhc2F21bgU1@mid.individual.net>
In reply to#18474
alex:

> $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

What is the content of data/regex and data/subject? The URLs you
mentioned? Why do you think that

https://files.fm/f/9mwzkn2wr

and

https://files.fm/f/8xeaybz5z

Will match?


-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#18478

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-27 14:59 +0100
Message-ID<rsa40i$1cub$1@gioia.aioe.org>
In reply to#18477
Il 27/12/20 14:43, Arno Welzel ha scritto:
> alex:
> 
>> $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
> 
> What is the content of data/regex and data/subject? The URLs you
> mentioned? Why do you think that
> 
> https://files.fm/f/9mwzkn2wr
> 
> and
> 
> https://files.fm/f/8xeaybz5z
> 
> Will match?
> 
> 

Instead of the content of the files I have published only the url, in 
order to download and consult them more comfortably.
But I see you didn't like this solution.

So I show them directly:

$ cat data/regex
#Mock message .+¶
.+¶
.+
\-\-\-\-\-
Backtrace dettagliato\:¶
.+¶
.+#s

$ cat data/subject
Exception: Mock message in 
tests/AlexSoft/Util/LoggerTextProcessing/DetailedBacktraceProcessorTest.php:31¶
Stack trace:¶
#0 vendor/phpunit/phpunit/src/Framework/TestCase.php(1526): 
AlexSoft\FavoriteExceptionHandler\Util\LoggerTextProcessing\DetailedBacktraceProcessorTest->testProcess()¶
#1 vendor/phpunit/phpunit/src/Framework/TestCase.php(1132): 
PHPUnit\Framework\TestCase->runTest()¶
#2 vendor/phpunit/phpunit/src/Framework/TestResult.php(722): 
PHPUnit\Framework\TestCase->runBare()¶
#3 vendor/phpunit/phpunit/src/Framework/TestCase.php(884): 
PHPUnit\Framework\TestResult->run()¶
#4 vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): 
PHPUnit\Framework\TestCase->run()¶
#5 vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): 
PHPUnit\Framework\TestSuite->run()¶
#6 vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): 
PHPUnit\Framework\TestSuite->run()¶
#7 vendor/phpunit/phpunit/src/TextUI/TestRunner.php(667): 
PHPUnit\Framework\TestSuite->run()¶
#8 vendor/phpunit/phpunit/src/TextUI/Command.php(142): 
PHPUnit\TextUI\TestRunner->run()¶
#9 vendor/phpunit/phpunit/src/TextUI/Command.php(95): 
PHPUnit\TextUI\Command->run()¶
#10 vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()¶
#11 {main}
-----
Backtrace dettagliato:¶
Array¶
(¶
     [0] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestCase.php¶
             [line] => 1526¶
             [function] => testProcess¶
             [class] => 
AlexSoft\FavoriteExceptionHandler\Util\LoggerTextProcessing\DetailedBacktraceProcessorTest¶
             [type] => ->¶
         )¶
¶
     [1] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestCase.php¶
             [line] => 1132¶
             [function] => runTest¶
             [class] => PHPUnit\Framework\TestCase¶
             [type] => ->¶
         )¶
¶
     [2] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestResult.php¶
             [line] => 722¶
             [function] => runBare¶
             [class] => PHPUnit\Framework\TestCase¶
             [type] => ->¶
         )¶
¶
     [3] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestCase.php¶
             [line] => 884¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestResult¶
             [type] => ->¶
         )¶
¶
     [4] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestSuite.php¶
             [line] => 677¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestCase¶
             [type] => ->¶
         )¶
¶
     [5] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestSuite.php¶
             [line] => 677¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestSuite¶
             [type] => ->¶
         )¶
¶
     [6] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestSuite.php¶
             [line] => 677¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestSuite¶
             [type] => ->¶
         )¶
¶
     [7] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/TextUI/TestRunner.php¶
             [line] => 667¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestSuite¶
             [type] => ->¶
         )¶
¶
     [8] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/TextUI/Command.php¶
             [line] => 142¶
             [function] => run¶
             [class] => PHPUnit\TextUI\TestRunner¶
             [type] => ->¶
         )¶
¶
     [9] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/TextUI/Command.php¶
             [line] => 95¶
             [function] => run¶
             [class] => PHPUnit\TextUI\Command¶
             [type] => ->¶
         )¶
¶
     [10] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/phpunit¶
             [line] => 61¶
             [function] => main¶
             [class] => PHPUnit\TextUI\Command¶
             [type] => ::¶
         )¶
¶
)¶

[toc] | [prev] | [next] | [standalone]


#18487

FromArno Welzel <usenet@arnowelzel.de>
Date2020-12-28 15:16 +0100
Message-ID<i4u7moFi1ebU1@mid.individual.net>
In reply to#18478
alex:

> Il 27/12/20 14:43, Arno Welzel ha scritto:
>> alex:
>>
>>> $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
>>
>> What is the content of data/regex and data/subject? The URLs you
>> mentioned? Why do you think that
>>
>> https://files.fm/f/9mwzkn2wr
>>
>> and
>>
>> https://files.fm/f/8xeaybz5z
>>
>> Will match?
>>
>>
> 
> Instead of the content of the files I have published only the url, in 
> order to download and consult them more comfortably.
> But I see you didn't like this solution.
> 
> So I show them directly:
> 
> $ cat data/regex
> #Mock message .+¶
> .+¶
> .+
> \-\-\-\-\-

This is not a valid regular expression.


-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#18479

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-27 15:11 +0100
Message-ID<rsa4n2$1n7h$1@gioia.aioe.org>
In reply to#18477
Il 27/12/20 14:43, Arno Welzel ha scritto:
> alex:
> 
>> $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
> 
> What is the content of data/regex and data/subject? The URLs you
> mentioned? Why do you think that
> 
> https://files.fm/f/9mwzkn2wr
> 
> and
> 
> https://files.fm/f/8xeaybz5z
> 
> Will match?
> 
> 

Instead of the contents of the files I published the url to download 
them, and consulate them more comfortably.
But I see that you didn't like this solution, so I publish them to you 
directly:

$ cat data/regex
#Mock message .+¶
.+¶
.+
\-\-\-\-\-
Backtrace dettagliato\:¶
.+¶
.+#s

$ cat data/subject
Exception: Mock message in 
tests/AlexSoft/Util/LoggerTextProcessing/DetailedBacktraceProcessorTest.php:31¶
Stack trace:¶
#0 vendor/phpunit/phpunit/src/Framework/TestCase.php(1526): 
AlexSoft\FavoriteExceptionHandler\Util\LoggerTextProcessing\DetailedBacktraceProcessorTest->testProcess()¶
#1 vendor/phpunit/phpunit/src/Framework/TestCase.php(1132): 
PHPUnit\Framework\TestCase->runTest()¶
#2 vendor/phpunit/phpunit/src/Framework/TestResult.php(722): 
PHPUnit\Framework\TestCase->runBare()¶
#3 vendor/phpunit/phpunit/src/Framework/TestCase.php(884): 
PHPUnit\Framework\TestResult->run()¶
#4 vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): 
PHPUnit\Framework\TestCase->run()¶
#5 vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): 
PHPUnit\Framework\TestSuite->run()¶
#6 vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): 
PHPUnit\Framework\TestSuite->run()¶
#7 vendor/phpunit/phpunit/src/TextUI/TestRunner.php(667): 
PHPUnit\Framework\TestSuite->run()¶
#8 vendor/phpunit/phpunit/src/TextUI/Command.php(142): 
PHPUnit\TextUI\TestRunner->run()¶
#9 vendor/phpunit/phpunit/src/TextUI/Command.php(95): 
PHPUnit\TextUI\Command->run()¶
#10 vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()¶
#11 {main}
-----
Backtrace dettagliato:¶
Array¶
(¶
     [0] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestCase.php¶
             [line] => 1526¶
             [function] => testProcess¶
             [class] => 
AlexSoft\FavoriteExceptionHandler\Util\LoggerTextProcessing\DetailedBacktraceProcessorTest¶
             [type] => ->¶
         )¶
¶
     [1] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestCase.php¶
             [line] => 1132¶
             [function] => runTest¶
             [class] => PHPUnit\Framework\TestCase¶
             [type] => ->¶
         )¶
¶
     [2] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestResult.php¶
             [line] => 722¶
             [function] => runBare¶
             [class] => PHPUnit\Framework\TestCase¶
             [type] => ->¶
         )¶
¶
     [3] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestCase.php¶
             [line] => 884¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestResult¶
             [type] => ->¶
         )¶
¶
     [4] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestSuite.php¶
             [line] => 677¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestCase¶
             [type] => ->¶
         )¶
¶
     [5] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestSuite.php¶
             [line] => 677¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestSuite¶
             [type] => ->¶
         )¶
¶
     [6] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/Framework/TestSuite.php¶
             [line] => 677¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestSuite¶
             [type] => ->¶
         )¶
¶
     [7] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/TextUI/TestRunner.php¶
             [line] => 667¶
             [function] => run¶
             [class] => PHPUnit\Framework\TestSuite¶
             [type] => ->¶
         )¶
¶
     [8] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/TextUI/Command.php¶
             [line] => 142¶
             [function] => run¶
             [class] => PHPUnit\TextUI\TestRunner¶
             [type] => ->¶
         )¶
¶
     [9] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/src/TextUI/Command.php¶
             [line] => 95¶
             [function] => run¶
             [class] => PHPUnit\TextUI\Command¶
             [type] => ->¶
         )¶
¶
     [10] => Array¶
         (¶
             [file] => vendor/phpunit/phpunit/phpunit¶
             [line] => 61¶
             [function] => main¶
             [class] => PHPUnit\TextUI\Command¶
             [type] => ::¶
         )¶
¶
)¶

[toc] | [prev] | [next] | [standalone]


#18480

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2020-12-27 15:33 +0000
Message-ID<87im8n9scy.fsf@bsb.me.uk>
In reply to#18474
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.

[toc] | [prev] | [next] | [standalone]


#18481

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-27 16:50 +0100
Message-ID<rsaag6$flf$1@gioia.aioe.org>
In reply to#18480
Il 27/12/20 16:33, Ben Bacarisse ha scritto:
> 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.

However, I need this to make sure that there are at least two lines 
between 'Mock message' and '-----'

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

echo preg_quote('-') . PHP_EOL;
echo preg_quote(':') . PHP_EOL;

Output:

\-
\:

[toc] | [prev] | [next] | [standalone]


#18482

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-27 17:14 +0100
Message-ID<rsabtr$16ks$1@gioia.aioe.org>
In reply to#18481
Il 27/12/20 16:50, alex ha scritto:
> Il 27/12/20 16:33, Ben Bacarisse ha scritto:
>> 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.
> 
> However, I need this to make sure that there are at least two lines 
> between 'Mock message' and '-----'
> 
>> Also, you don't need \ before - or :.
> 
> echo preg_quote('-') . PHP_EOL;
> echo preg_quote(':') . PHP_EOL;
> 
> Output:
> 
> \-
> \:
> 

Clarification:

In my specific case, the subject consists of two sections;

- Exception
- Backtrace dettagliato

The lines that make up every section are separated by "¶\n".
The "\n-----\n" represents the sections separator.

PS

Of course, "\n" means the carriage return (PHP_EOL).

[toc] | [prev] | [next] | [standalone]


#18484

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2020-12-28 02:02 +0000
Message-ID<877dp2adsw.fsf@bsb.me.uk>
In reply to#18482
alex <1j9448a02@lnx159sneakemail.com.invalid> writes:

> Il 27/12/20 16:50, alex ha scritto:
>> Il 27/12/20 16:33, Ben Bacarisse ha scritto:
>>> 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.
>>
>> However, I need this to make sure that there are at least two lines
>> between 'Mock message' and '-----'

I would ask for that explicitly, rather than relying on the
backtracking:

(:?[^\n]*\n){2,}-----

>>> Also, you don't need \ before - or :.
>>
>> echo preg_quote('-') . PHP_EOL;
>> echo preg_quote(':') . PHP_EOL;
>>
>> Output:
>>
>> \-
>> \:

Should I have been more precise?  You don't need \ before - or : in the
pattern you wrote.

<cut>
> PS
>
> Of course, "\n" means the carriage return (PHP_EOL).

"\n" means linefeed (sometimes called newline).  PHP_EOL is often "\n"
but not always.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#18486

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-28 10:38 +0100
Message-ID<rsc93a$r8q$1@gioia.aioe.org>
In reply to#18484
Il 28/12/20 03:02, Ben Bacarisse ha scritto:
>>>> Also, you don't need \ before - or :.
>>> echo preg_quote('-') . PHP_EOL;
>>> echo preg_quote(':') . PHP_EOL;
>>>
>>> Output:
>>>
>>> \-
>>> \:
> Should I have been more precise?  You don't need \ before - or : in the
> pattern you wrote.

You're right, I'm sorry.

>> PS
>>
>> Of course, "\n" means the carriage return (PHP_EOL).
> "\n" means linefeed (sometimes called newline).  PHP_EOL is often "\n"
> but not always.

OK.
Anyway thanks for the suggestions.
Now I will review my code, to make sure I achieve my goal.

Happy New Year!!!

[toc] | [prev] | [next] | [standalone]


#18488 — Re: PHP_EOL (was: preg_match() return false)

From"J.O. Aho" <user@example.net>
Date2020-12-28 15:43 +0100
SubjectRe: PHP_EOL (was: preg_match() return false)
Message-ID<i4u995FicpbU1@mid.individual.net>
In reply to#18484
On 28/12/2020 03.02, Ben Bacarisse wrote:
> alex <1j9448a02@lnx159sneakemail.com.invalid> writes:

>> Of course, "\n" means the carriage return (PHP_EOL).

carriage return is \r


> "\n" means linefeed (sometimes called newline).  PHP_EOL is often "\n"
> but not always.

PHP_EOL value depends on the default on the OS, in <5.6.30 version there 
was \r\n (microsoft windows), \r (MacOS/OSX), and \n (other OS:es) while 
later versions it's just \r\n (microsoft windows) and \n (other OS:es).

PHP_EOL has limited use, as it follows the OS and not standards like 
e-mail headers.


-- 

  //Aho

[toc] | [prev] | [next] | [standalone]


#18491 — Re: PHP_EOL

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-12-29 15:55 +0100
SubjectRe: PHP_EOL
Message-ID<rsfg1g$1bd1$1@gioia.aioe.org>
In reply to#18488
Il 28/12/20 15:43, J.O. Aho ha scritto:
> 
> PHP_EOL value depends on the default on the OS, in <5.6.30 version there 
> was \r\n (microsoft windows), \r (MacOS/OSX), and \n (other OS:es) while 
> later versions it's just \r\n (microsoft windows) and \n (other OS:es).
> 
> PHP_EOL has limited use, as it follows the OS and not standards like 
> e-mail headers.

thanks for the info

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web