• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 424
  • Last Modified:

Need built in jQuery "string endsWith" functionality

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
newbieweb
Asked:
newbieweb
  • 3
1 Solution
 
pivarCommented:
Hi,

Try

str.match(/Error.jpg$/)

/peter
0
 
pivarCommented:
Oh sorry, should be

str.match(/Error\.jpg$/)
0
 
pivarCommented:
And to test if it ends with

if (str.match(/Error\.jpg$/) != null)
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now