Regular Expressions In Use

[Total: 0    Average: 0/5]

This shows how to use the regular expressions to find a pattern in a string.

Body Code:

<form name=exf1>
<BR> String: <input type=text name=t1 value="A red shoe and a blue shoe make a purple shoe?">
<BR> Search For: <input type=text name=t2 value="shoe" onfocus="resetIt()">
<BR> Result[0]: <input type=text name=t3 value="?">
<BR> Result.Index: <input type=text name=t4 value="?">
<BR><input type=button value="run search" onclick="searchMe()">
<script type=text/javascript>
function resetIt() {
function searchMe() {
  var result;
  var returnvalue = "";
  var text = document.exf1.t1.value;
  var pattern = eval("/"+document.exf1.t2.value+"/i");
  var result = pattern.exec(text);
  if (!result) return;

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *