Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Reg Ex Help! 1

Status
Not open for further replies.

CJAI

MIS
Oct 21, 2003
224
US
I need to validate a file path so that it has the following format. The bolded text is what I need to validate.
Code:
[b]W:\Documentation Team Shares\[/b]some folder[b]\Draft\[/b]Some File name

Any help is highly appreciated as I'm not too fond of regular expressions.
 
this ought to do it:

Code:
<script type="text/javascript">
	var s1 = "W:\\Documentation Team Shares\\some folder\\Draft\\Some File name";
	var s2 = "W:\\Documentation Team Shares\\some folder\\other folder\\Draft\\Some File name";
	var s3 = "W:\\Documentation Team Shares\\some folder\\Draft\\Some File name.extension";

	var re = /^W:\\Documentation Team Shares\\[\w\s]+\\Draft\\[\w\s\.]+$/;

	alert(s1 + "\n" + re.test(s1));
	alert(s2 + "\n" + re.test(s2));
	alert(s3 + "\n" + re.test(s3));
</script>




==============================================================================================

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top