Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Regular expensions in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 45
    Comment on it

    Welcome to FindNerd. Today we are going to discuss the pattern making for regular expersions in php. We use the inbuild functions named preg_match and preg_match_all to find the matching one from the string. Before starting using this functions you need to undertand the rules for pattern making. PHP use the perl compatible Regular expression(PCRE) syntax fpr regular expressions.Please check an small example.

    <?php
    $web_url = 'http://www.google.com';
    echo $total_one = preg_match('#http\/\/#',$web_url);
    ?> 
    result : 1
    

    In above example we can see the function preg_match which will return 1 because it found http:// substring only one time. If there is no match then it will return 0. preg_match function will stop when first match is found. If one sub string found multiple time in string then you need to use the preg_match_all function. We will discuss it next blog. When we make the pattern then we enclose it in delimiters. Delimiters are non-alphanumeric, non-backslash and non-whitespace characters like / string / , # string # , % string % etc

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: