A regular related question to the

Source: Internet
Author: User
A regular problem.
Asked the next Lao Xu, but the old Xu is very busy recently obviously the news also did not have time to see, then sent to everybody research research

Can match the following two kinds of situations, not one of them ...

Http://www.uploadfr.com/images/2014/03/20/204417dydmmeowem3mlnl0.jpg.thumb0608f2.jpg http://www.uploadfr.com/ Images/2014/03/20/204417dydmmeowem3mlnl0.jpg
------Solution--------------------
/^http://www.uploadfr.com/images/\d{4}/(\d{2}/) {2}\s*.jpg$/
------Solution--------------------


$str 1 = ' http://www.uploadfr.com/images/2014/03/20/204417dydmmeowem3mlnl0.jpg.thumb0608f2.jpg ';
$str 2 = ' http://www.uploadfr.com/images/2014/03/20/204417dydmmeowem3mlnl0.jpg ';

$pattern = '/^http:\/\/www\.uploadfr\.com\/images\/(\d{4}) \ (\d{2})/(\d{2}) \ ([a-z0-9]+) \. (jpg
------Solution--------------------
Png
------Solution--------------------
Gif
------Solution--------------------
JPEG) (\.thumb ([a-z0-9]{6}) \.\\5)? $/';

Preg_match ($pattern, $str 1, $match 1);
Preg_match ($pattern, $str 2, $match 2);

Print_r ($match 1);
Print_r ($match 2);

------Solution--------------------
See if this is the case, because you don't know the accuracy you want to match, write one first.

$content =<< <>
Word-word word-word character-word-word-word word-word-word-word-word-word-word-word-word-word-word-word-word 204417dydmmeowem3mlnl0.jpg.thumb0608f2.jpg word-word word-word character-word-character http://www.uploadfr.com/images/2014/03/20/ 204417dydmmeowem3mlnl0.jpg word-word word-word character word-word character word-character
TXT;

Preg_match_all ('/http:\/\/www.uploadfr.com\/images\/\d{4}\/\d{2}\/\d{2}\/\d{6}.*?jpg (\.thumb[a-z0-9]{6}\.jpg)? /si ', $content, $matches);

Print_r ($matches [0]);

Don't know dydmmeowem3mlnl0 this you need to match? If we're going to change this,
Preg_match_all ('/http:\/\/www.uploadfr.com\/images\/\d{4}\/\d{2}\/\d{2}\/\d{6}[a-z0-9]{16}\.jpg (\.thumb[a-z0-9 ]{6}\.jpg)/si ', $content, $matches);

------Solution--------------------
1. I didn't get your message.
2, such a rule string ' #http://\s+\.jpg\b# ' Can't you?
------Solution--------------------
References:
1. I didn't get your message.
2, such a rule string ' #http://\s+\.jpg\b# ' Can't you?

He must have had a special request, and he didn't understand.
A question was not clear, the criticism.
------Solution--------------------
There should be no special requirement, except that the first case has a string with a jpg ending
So you can't use non-greedy mode.

Reference:
Quote: Reference:

1. I didn't get your message.
2, such a rule string ' #http://\s+\.jpg\b# ' Can't you?

He must have had a special request, and he didn't understand.
A question was not clear, the criticism.

------Solution--------------------
Show concern
  • 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.