I have a string
$str = 'abcde-da__123123213.xef';
$str2 = 'asdfasd__2342352353.gff';
$str3 = 'twethe__3242323423.pig';
I want to replace anything following __ (2 underscores) and before the . (dot) with a new string (number). For example, the above $str
changes to 'abcde-da__23235239.xef'.
One of the ways is to
$temp = explode('.', $str);
$temp2 = explode('__', $temp[0]);
and
$new_str = $temp2[0].'__'.time().'.'.$temp[1];
But I was thinking if I could use preg_replace instead but I aint very good at regexs
i tried preg_replace('/__(.*)/', time(), 'abcde-da__123123213.xef');
can you please help writing this regex, or any other simpler way?
Thanks