I am trying to learn regex and have a string, I want the beginning to be (not including)
.com/
and the end to be (not including)
">[tomato
I can make the basic regex ok, but it keeps including the tomato part in it, instead of ending just before it. So if I have
'sdf98uj3.com/sdjkh.sdf./sdf.sdf">[tomatoiosdf8uj3'
, then I want to return:
sdjkh.sdf./sdf.sdf
I am using preg_match in php. Any ideas?
$match[1]contains your string. The(.*?)is a capture group that captures every character between.com/and">[tomato.http://www.regular-expressions.info/ is a good start for learning regular expressions.
Could also be solved without regex, using
strpos(docs),strrpos(docs) andsubstr(docs):