Regex rewriting Amazon URLs
-
Can somebody tell me what am I doing wrong? This works on the various online REGEX testers such as https://regex101.com, but I can’t get it to work with this plugin.
Input HTML:
words words words <a href="https://www.amazon.com/product-name/dp/10DIGIASIN/">link text</a> words words words
Search REGEX:
amazon\.com\/\S{1,150}\/dp\/(\S{10})\/
Substitution REGEX:
amazon.com/dp/\1/ref=nosim?tag=whatever-20/" target="_blank" rel="noreferrer noopener"
Desired output HTML (remove the product-name, retain the 10-digit ASIN, add affiliate code):
words words words <a href="https://www.amazon.com/dp/10DIGIASIN/ref=nosim?tag=whatever-20/" target="_blank" rel="noreferrer noopener">link text</a> words words words
As soon as I try anything more complex like
/S{1,150}
it fails.
- The topic ‘Regex rewriting Amazon URLs’ is closed to new replies.