Page 334 - CITS - CSA - TP (Volume 1) - Hindi
P. 334
कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS
II म ी मैच के िलए preg_match_all() का उपयोग करना (Using preg_match_all() for Multiple Matches)
1 टे एिडटर ओपन कर
2 िन िल खत कोड िलख
<html >
<head>
<title> Using preg_match_all()</title>
</head>
<body>
<?php
$str = “The rain in SPAIN falls mainly on the plains.”;
$pattern = “/ain/i”;
echo preg_match_all($pattern, $str);
?>
</body>
</html>
3 ो ाम को C:\Apache24\htdocs म .php ए ट शन वाले फ़ो र म सेव कर
4 िवंडोज़ सिव स से Apache सिव स रन कर
5 ाउज़र ओपन कर और िन एड ेस टाइप कर
http://localhost/foldername/
6 रन करने के िलए php फ़ाइल पर क कर और आउटपुट वेरीफाई कर t
III र ेसम ट के िलए preg_replace() का उपयोग करना (Using preg_replace() for Replacement)
1 टे एिडटर ओपन कर
2 िन िल खत कोड िलख
<html >
<head>
<title> Using preg_replace() </title>
</head>
<body>
<?php
$str = “Visit Microseft!”;
$pattern = “/microsoft/i”;
echo preg_replace($pattern, “Google”, $str);
318
CITS : IT & ITES - कं ूटर सॉ वेयर ए ीके शन - अ ास 58

