replace strings in url using regular expression

user3929607

I am really poor in regular expressions, So that is the reason i am asking the basic question here. I want to change some strings with slashes in a url in javascript. Please help me to get out from this.

This is my url

http://mysite.local/media/catalog/product/cache/1/thumbnail/56x/qewewq1312321dfde5fb8d27136e95/m/u/music6_1_1.jpg

And i want to replace 'thumbnail/56x' with 'image' like

http://mysite.local/media/catalog/product/cache/1/image/qewewq1312321dfde5fb8d27136e95/m/u/music6_1_1.jpg

How can i get with regular expression?

Avinash Raj

thumbnail\/56x regex would replace the exact thumbnail/56x part in your link with image.

> "http://mysite.local/media/catalog/product/cache/1/thumbnail/56x/qewewq1312321dfde5fb8d27136e95/m/u/music6_1_1.jpg".replace(/thumbnail\/56x/g, "image")
'http://mysite.local/media/catalog/product/cache/1/image/qewewq1312321dfde5fb8d27136e95/m/u/music6_1_1.jpg'

thumbnail\/\d+x regex would replace any number in the thumbnail part like thumbnail/673px with image.

> "http://mysite.local/media/catalog/product/cache/1/thumbnail/56x/qewewq1312321dfde5fb8d27136e95/m/u/music6_1_1.jpg".replace(/thumbnail\/\d+x/g, "image")
'http://mysite.local/media/catalog/product/cache/1/image/qewewq1312321dfde5fb8d27136e95/m/u/music6_1_1.jpg'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Regular expression with URL Encoded Strings

From Dev

PHP Regular expression replace for url

From Dev

Find & replace url to HTML tag using regular expression

From Dev

Replace string using Regular expression

From Dev

Find and replace with two strings between it with regular expression

From Dev

Regular Expression - detect Specific Url and replace that string

From Dev

How to write this regular expression to only replace url

From Dev

comparing two strings using perl regular expression

From Dev

How to split 2 strings using regular expression?

From Dev

How to match multiple strings using regular expression?

From Dev

Find and replace "[" and,or "]" using regular expression in PHP

From Dev

Regular Expression to insert using replace method in Javascript

From Dev

Replace space with hyphen using regular expression

From Dev

Using regular Expression to replace emotions character in javascript

From Dev

replace sections of top lines using regular expression

From Dev

Replace using regular expression with replacement function

From Dev

using mysql regex_replace with a regular expression

From Dev

replace URLs but not images using a regular expression

From Dev

Perl multiline replace with spaces / using regular expression

From Dev

Using Notepad++ find and replace with regular expression

From Dev

replace String with another in java using regular Expression

From Dev

Find and replace "[" and,or "]" using regular expression in PHP

From Dev

Using regular Expression to replace emotions character in javascript

From Dev

using mysql regex_replace with a regular expression

From Dev

replace a string in all occurence using regular expression

From Dev

replace a substring in python using regular expression

From Dev

Regular expression replace using Sublime Text 3

From Dev

Unable to replace a string using a regular expression

From Dev

replace URLs but not images using a regular expression

Related Related

  1. 1

    Regular expression with URL Encoded Strings

  2. 2

    PHP Regular expression replace for url

  3. 3

    Find & replace url to HTML tag using regular expression

  4. 4

    Replace string using Regular expression

  5. 5

    Find and replace with two strings between it with regular expression

  6. 6

    Regular Expression - detect Specific Url and replace that string

  7. 7

    How to write this regular expression to only replace url

  8. 8

    comparing two strings using perl regular expression

  9. 9

    How to split 2 strings using regular expression?

  10. 10

    How to match multiple strings using regular expression?

  11. 11

    Find and replace "[" and,or "]" using regular expression in PHP

  12. 12

    Regular Expression to insert using replace method in Javascript

  13. 13

    Replace space with hyphen using regular expression

  14. 14

    Using regular Expression to replace emotions character in javascript

  15. 15

    replace sections of top lines using regular expression

  16. 16

    Replace using regular expression with replacement function

  17. 17

    using mysql regex_replace with a regular expression

  18. 18

    replace URLs but not images using a regular expression

  19. 19

    Perl multiline replace with spaces / using regular expression

  20. 20

    Using Notepad++ find and replace with regular expression

  21. 21

    replace String with another in java using regular Expression

  22. 22

    Find and replace "[" and,or "]" using regular expression in PHP

  23. 23

    Using regular Expression to replace emotions character in javascript

  24. 24

    using mysql regex_replace with a regular expression

  25. 25

    replace a string in all occurence using regular expression

  26. 26

    replace a substring in python using regular expression

  27. 27

    Regular expression replace using Sublime Text 3

  28. 28

    Unable to replace a string using a regular expression

  29. 29

    replace URLs but not images using a regular expression

HotTag

Archive