Showing posts with label Regex. Show all posts
Showing posts with label Regex. Show all posts

Monday, October 19, 2015

Regex to Catch image in img tag

<img .*?src="[^"]*\/\K([^"]*?\.(?:jpeg|jpg|bmp|gif|png))

My Name in Regex!

^([\+?I?])([\+?n?])([\+?d?])([\+?e?])([\+?r?])([\+?a?])(\d{0,9})$

Useful websites to learn Regex

Basic Tutorial
  1. http://www.macronimous.com/resources/writing-regular-expression-with-php.asp
Regex Website Tester
  1. https://regex101.com/

Regex to Valid Phone Number (Malaysia)

     function valid_phone_num($str)
     {
     if (!preg_match("/^(\+?6?01)[0|1|2|3|4|6|7|8|9]\-*[0-9]{7,8}$/", $str)):
       $this->form_validation->set_message('valid_phone_num', 'Please insert a valid phone number format. Example : 0191234567.');
       return FALSE;
     else:
       return TRUE;
    endif;
    }