Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<script type="text/javascript">
var str = "abc";
var patt1 = /^[a-z]$/;
if(patt1.test(str))
{
document.write(str);
alert(str);
}
</script>

i want to make regular expression for string if it match then alert
what problem in this code?
Posted
Comments
Sebastian T Xavier 21-Jul-12 0:09am    
Challenging?

1 solution

It only matches a single character in the range 'a' to 'z' - I suspect you need:
^[a-z]*$
instead
 
Share this answer
 
Comments
nilesh026 20-Jul-12 4:50am    
thanx to giving me solution
i try ^[a-z]*$ also but not working
OriginalGriff 20-Jul-12 4:53am    
"but not working" is not very helpful.
What is it doing that it shouldn't, or not doing that it should?
Sebastian T Xavier 21-Jul-12 0:10am    
Why accepting it, if it is not working?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900