Regex: Extract parts of url before and after last period -


i have url (http://www.something.com/subdirectory/image.jpg) , split url 2 parts using regex:

1) capture first part of url before last period (http://www.something.com/subdirectory/image)

2) capture last part of url after last period (jpg)

the file extension not jpg.

i have come far capturing string before first period instead of last:

/([^.]*)\.(.*)/ 

edit: here's i'm trying do. replace current src adding "_on" end of image name.

$(this).attr("src").replace(/(.*)\.([^.]+)$/, "$1_on.$2") 

thanks in advance , help, b

try with

/(.*)\.(.+)/ 

i think it'll works.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -