I have problem with reg ex. in PHP
I have string like:
sdfsfds dsfdsh kj <img src="cid:sdfsdf/img.jpg@23232"> sdfd sfdhg sdjhg sdfsfds dsfdsh kj <img src="cid:sdfsdf/img.jpg@23232"> sdfd sfdhg sdjhg
I want to grab everything between ‘cid:’ and ‘”>’ and replace it with something else.
Here is my reg ex:
cid:.*img\.jpg.*\"
What do I get in return??
cid:sdfsdf/img.jpg@23232"> sdfd sfdhg sdjhg sdfsfds dsfdsh kj <img src="cid:sdfsdf/img.jpg@23232"
insead of double
cid:sdfsdf/img.jpg@23232
why??
Your regex is greedy. Use non-greedy quantifiers by adding a
?after them:http://en.wikipedia.org/wiki/Regular_expression#Lazy_quantification