Solved

Need built in jQuery "string endsWith" functionality

Posted on 2011-09-28
4
359 Views
Last Modified: 2012-05-12
I need to use jQuery to find if a string ends with "Error.jpg";

I use var but could use any type you suggest.

How do I do this?

Thanks.
0
Comment
Question by:newbieweb
  • 3
4 Comments
 
LVL 22

Expert Comment

by:pivar
ID: 36717480
Hi,

Try

str.match(/Error.jpg$/)

/peter
0
 
LVL 22

Accepted Solution

by:
pivar earned 500 total points
ID: 36717484
Oh sorry, should be

str.match(/Error\.jpg$/)
0
 
LVL 22

Expert Comment

by:pivar
ID: 36717504
And to test if it ends with

if (str.match(/Error\.jpg$/) != null)
0
 

Author Closing Comment

by:newbieweb
ID: 36717573
Thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question