I am trying to use regular expressions within JavaScript for the picture upload component of a shopping cart. I still can't seem to get my mind around them.

I have a page with a working file upload. When you click on browse and then select your file, the file name is also returned to the second field, the picture name field. The problem is that the entire string is returned - 'G:\Catalog\MyPictures\somepic.jpg' instead of 'somepic.jpg'.

I know this can be pulled out with regular expressions, everything from the right until it hits a / or \ I included the script and a couple of links.

working example http://www.westmichiganwebservices.com/conn.asp

reg exp javascript tutorial http://www.webreference.com/js/column5/define.html

working javascript code thus far -
<script language="JavaScript" type="text/javascript">
function addname() {
 var newfile = document.form1.upload_field.value;
 //newfile = the result of some regular expression;
 document.form1.filename.value = newfile;
 return false;