1. mawe
  2. RO CSVI
  3. Wednesday, 20 December 2017
  4.  Subscribe via email
Hi

I try to find image file names (four digits, filetype .png) and do a replace to build a complete img-tag.

My Problem: I don't know how to insert the matching string (found filename) in the replacement part of the rule.

I tryed \1 but it doesn't work.

Regards

Martin
Accepted Answer Pending Moderation
Hello Martin,

You may need to use \\1 instead of \1. Did you try that? I am no guru with regular expressions either ;)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
Hello Roland

The suggested solution with doubling the backslashes did not work. But after "playing around" for a while with the regex, I read the decisive sentence in the PHP documentation:

"However, if the decimal number following the backslash is less than 10, it is always taken as a back reference, and causes an error only if there are not that many capturing left parentheses in the entire pattern. "

So I added some parentheses in my find term

Find: /(\d{4}.png)/

Replace: \1

- and it worked!

Greetings from Switzerland

Martin
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Hello Martin,

Thank you for posting your solution.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!