Ask for a regular question

Source: Internet
Author: User
 
  
  
Positive Salary:
2000-3000 RMB , trial salary 60%



I want to take
..
Between non- In the content, with [^ ...] I don't think I can write it, I know. Replace the contents of the. Are there any other matches that can be successfully matched with only one regular?


Reply to discussion (solution)

/
 
  
  
(.*?) (?:<\!\-\-.*?\-->) (.*?) /ius

/
 
  
  
(.*?) (?:<\!\-\-.*?\-->) (.*?) <\/dd>/ius

It might be more efficient to match it first and then replace it.

Chinmo, how do I try not to succeed, did you test?

$s =<<
 <>
  
  
Positive Salary:
2000-3000 Yuan , trial salary 60%
html;preg_match ('/
(. +?) <\!--. +?--> (. +?) <\/dd>/s ', $s, $m); echo $m [1]. $m [2];

2000-3000 USD

, Trial salary 60%

Chinmo, how do I try not to succeed, did you test?
Well, I don't know how you tested it.

$s = '


Positive Salary:

2000-3000 USD

, Trial salary 60%

';
Preg_match ('/
(.*?) (?:<\!\-\-.*?\-->) (.*?) <\/dd>/ius ', $s, $m);
echo $m [1]. $m [2];

Anyway, I did the test.

$s = '
  
   
  
Positive Salary:
2000-3000 yuan , trial salary 60%
';p reg_match ('/
(. *?) (?:<\!\-\-.*?\-->) (.*?) <\/dd>/ius ', $s, $m); echo $m [1]. $m [2];

Results:

Preg_match ("/(. *?) (.*?) /", $STR, $arr);
Echo $arr [2];

/

(.*?) (?:<\!\-\-.*?\-->) (.*?) <\/dd>/is
The U modifier is valid only for UTF-8 encoded data
Besides, you don't have to deal with Chinese.

Is it really that simple?
Preg_match ('/
(. *?) <\/dd>/is ', $s, $m);
Echo Strip_tags ($m [1]);

No wonder, I just was GBK code, no wonder it won't show

Xuzuning method is good, originally PHP and Strip_ Tags This function, is really more convenient.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.