Page 309 - Computer Software Application TP - Volume 1
        P. 309
     COMPUTER SOFTWARE APPLICATION - CITS
           EXERCISE 58 : Demonstrate Regular  Expressions -  The
                                     basic regular expressions, PCRE, Matching
                                     patterns,           Finding           matches,             Replace
                                     patterns, Modifiers, Breakup Strings
            Objectives
           At the end of this exercise you shall be able to:
           •  use the basic regular expressions in PHP
           •  use PCRE function in PHP.
           Requirements
           Tools/Materials
           •   Computer/Laptop with latest configuration       •  PHP
           •   Operating system: windows 10 or 11              •  Text editor
           •  Apache web server                                •  Web browser
           Procedure
           TASK 1: Working with basic regular expressions
           I  Matching a single character
              1  Open the text editor
              2  Write the following codes
                          <html >
                 <head>
                     <title > Matching a single character </title>
                 </head>
                 <body>
                        <?php
                   $string = “Hello, world!”;
                   $pattern = “/w/”;  // Matches any word character (alphanumeric or underscore)
                   if (preg_match($pattern, $string))
                   {
                    echo “Match found!”;  // Output: Match found!
                   }
                 ?>
                 </body>
                 </html>
                 3   Save the program in C:\Apache24\htdocs in a folder with .php extension
                 4   Run the Apache services from windows services
                 5   Open the browser and type the following address
                                                           294
                                                                                                                                                      CITS : IT & ITES - Computer Software Application - Exercise 58
     	
