Hi
I have the following code that lists first names of people who's
surnames are 'Morris'. What I am trying to do is search for first names that
don't start at the beginning of the line ie. have the '[^\^]' in the regExp
object, but 'Neil' is matched even though it is next to(?) the start of line
char(?) or should I say 'Neil' is the first 'word' of the string?
here's the code
<html>
<head>
<title>
my RegExp
</title>
</head>
<body>
<script>
var myPat = new RegExp("([^\\^]\\w+) Morris","gi");
var str = new String("Neil Morris Lee Morris Jenny Morris Jackie Morris mai
Morris wong Morris write Morris");
var count=1;
while(myArray=myPat.exec(str)) {
for(i=1;i<myArray.length;i++) {
document.write(+count+"=array\["+i+"\] \""+myArray[i]+"\"<br>");
}
document.write("RegExp objects methods and results<br>");
document.write("myPat.lastIndex="+myPat.lastIndex+ "<br>");
document.write("myPat.source="+myPat.source+"<br>" );
document.write("array from RegExp object exec method<br>");
document.write("method index="+myArray.index+"<br>");
document.write("method input="+myArray.input+"<br>");
document.write("method \[0\]=#"+myArray[0]+"<br>");
document.write("string before
match=#"+myArray.input.substring(0,myArray.index)+ "#<br>");
document.write("string after
match=#"+myArray.input.substring(myArray.index+myA rray[0].length)+"#<br>");
document.write("<hr>");
count++;
}
</script>
</body>
</html>
--
my IE6 favorites (bookmarks URL's)
http://www.myjavaware.co.uk/bookmark.htm