Click here to Skip to main content
15,904,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
how to check the variable contains the extension or not,
I defined like var file = file1.prj.
I want to check whether the variable contains prj or not in java script.
how can I do this
Posted

1 solution

Steps:
1. Based on '.' as a delimiter, split the variable into array
2. Check the 2nd value if you are sure that variable will always be of format xxx.yyy
3. If array length is more than one, based on the defined format, variable contains extension.

Refer: JavaScript split() Method[^]

Try out.
 
Share this answer
 

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