On PHP question: From string "192.168.0.23, 192.168.2.33, 124.125.126.127" remove IP address ", 124.125.126.127". leave only: "192.168.0.23, 192.168.2.33"
Thank you.
On PHP question: From string "192.168.0.23, 192.168.2.33, 124.125.126.127" remove IP address ", 124.125.126.127". leave only: "192.168.0.23, 192.168.2.33"
Thank you.
Use this regex: /[\w.]{15}/
and replace with nothing or empty string ""
.
<?php
$string = '192.168.0.23, 192.168.2.33, 124.125.126.127';
$pattern = '/[\d.]{15}/';
$replacement = '';
echo preg_replace($pattern, $replacement, $string);
?>
Then, remove the last comma with some native php string function. (I don't know much about php)
Demo: http://ideone.com/xNCVNC
<?php
$str='192.168.0.23, 192.168.2.33, 124.125.126.192';
print_r(array_filter(explode(', ',$str),function ($v){ return substr($v,0,3)=='192'?$v:''; }));
OUTPUT :
Array
(
[0] => 192.168.0.23
[1] => 192.168.2.33
)