<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title></title>

    </head>

    <body>

        <form name="form1" method="post" action="RegExpSimulator.php">

            Content<br/>

            <textarea name="txaContent" style="height: 204px; width: 559px" rows="3" >

<?php if(isset($_POST["txaContent"]))

echo htmlentities($_POST["txaContent"]);

else

echo "use napel use nepal suraj shrestha werwe terwtr wer nepal uraj"

?>

            </textarea>

            <br />

            <br />

            <br/>

            Regular Expression <br />

            <input type="text" name="txtRegExp" style="height: 46px; width: 563px"  value='<?php if(isset($_POST["txtRegExp"])) echo htmlentities($_POST["txtRegExp"]); else echo " ([^ ]*) nepal"; ?>' />

            <br />

            <br />

            <br/>

            <input type="submit" name="btnSubmit" value="Submit"  />

            <br />

            <?php

            if(isset ($_POST["txaContent"])){

                if(isset ($_POST["txtRegExp"])){

                    $regExp = $_POST["txtRegExp"];

                    $content = $_POST["txaContent"];

                    try{

                        preg_match_all("/".$regExp."/",$content, $links);

                    }

                    catch(Exception $ex){

                        echo "Error :".$ex->getMessage();

                    }

                }

                $display = "<br />";

                $i =1; $j = 0;

                if(count($links)>0){

                    for($j = 0; $j < count($links[0]) ; $j++){

                        echo(($j+1).")  ");

                        for($i =1; $i < count($links); $i++){

                            $links[$i][$j] = htmlentities($links[$i][$j]);

                            echo("....[".$links[$i][$j]."]....");

                        }

                        echo("<br />");

                    }

                }

                echo("<br />i :".($i-1)."<br />j :".$j."<br />");

            }

            ?>

        </form>

    </body>

</html>