Page 337 - CITS - CSA - TP (Volume 1) - Hindi
P. 337

कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS
















           VI     ंग म  िवशेष करै र को ए े प करने के  िलए preg_quote() का उपयोग करना (Using preg_quote() for escapes special
              characters in a string)

              1  टे  एिडटर ओपन कर

              2  िन िल खत कोड िलख
                             <html >

                    <head>

                          <title> Using preg_quote() </title>
                    </head>

                    <body>

                            <?php
                 // String containing characters to be quoted

                 $string = “Escaping: .\+*?[^]{}()$=!|:-”;

                 // Quote the string to escape regular expression characters
                 $quotedString = preg_quote($string);

                 // Regular expression pattern containing the quoted string
                 $pattern = ‘/^  . $quotedString . ‘$/ ;
                 // Test string to match against the pattern

                 $testString = “Escaping: .\\+*?[^]{}()$=!|:-”;
                 // Perform regular expression matching
                 if (preg_match($pattern, $testString)) {

                          echo “String matches the pattern.\n”;
                 } else {

                          echo “String does not match the pattern.\n”;

                 }

                 ?>
                 </body>

                    </html>

              3   ो ाम को C:\Apache24\htdocs म  .php ए ट शन वाले फ़ो र म  सेव कर
              4  िवंडोज़ सिव स से Apache सिव स रन कर



                                                           321

                                     CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 58
   332   333   334   335   336   337   338   339   340   341   342