Matching a multiple lines pattern via PHP's preg_match()

后端 未结 6 852
轻奢々
轻奢々 2020-12-10 00:33

How can I match subject via a PHP preg_match() regular expression pattern in this HTML code:

      
6条回答
  •  执笔经年
    2020-12-10 01:01

    You have to remove all line breaks using \s in the regular expression:

    $str ="
    1. Capable for unlimited product
    2. Two currency support
    3. Works with touch screens and click screen based systems
    4. Responsive design shopping cart, Specially design for Mac, iPhone, iPad, PC and Android
    5. VAT for countries that support a Value Added Tax
    6. Barcode scanner checkout option for POS
    7. mRSS
    "; preg_match("/^([A-Za-z0-9\s\<\>\.\,\/\-\ ]+)$/", $str); // Sanitize your code before save to database. function test_input($data) { $data = trim($data); $data = htmlspecialchars($data); $data = json_encode($data); $data = addslashes($data); return $data; } echo test_input($str);

提交回复
热议问题