[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

preg_match problem with line breaks

Hello Experts,

I´m using the following preg_match expression:

if (preg_match("/^FULLTEXT:(.*)",$description,$descarr))

to filter a variable called $description.

The following works fine:

$description = "FULLTEXT: Hello World, i´m a text";

As soon as i use line breaks, the preg_match does not work any more... e.g.
$description = "FULLTEXT: Hello World, i´m a text
                        And this is another line ";

The reason why there´s a line break is that the $description is a textarea field from a post form.

Does anybody know how i can tell preg_match to regard line breaks.
1 Solution
use /s at the end of the regex to match for multiple lines.
if ( preg_match("/^FULLTEXT:(.*)/s",$description,$descarr) )

Open in new window


Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now