Other DB Replacer questions

Fix internal links to Joomla link structure

Buldre -'s Avatar Buldre -

A website with many internal links has unfortunately linked with the relative part of the SEO-friendly URL, instead of with the Joomla internal link structure. I now want to correct the links to Joomla's link structure. Fortunately, the relative portion of the SEO-friendly links includes both category names and article numbers, so I have something to grab onto. I want the structure to change as follows.

<a href="category1/3500-some-old-stuff.html">Some old stuff</a></p>
<a href="index.php?option=com_content&amp;view=article&amp;id=3500&amp;catid=1">Some old stuff</a></p>
<a href="category2/3501-my-new-content-article">My new content article</a></p>
<a href="index.php?option=com_content&amp;view=article&amp;id=3501&amp;catid=2">My new content article</a></p>
And so on. I don't know much about regular expressions, but have tried the following search:
<a href="category2/(.*?)-([\a-zA-Z0-9]+)[\>]
And replacement:
<a href="index.php?option=com_content&view=article&id=\1&catid=2">
This seems to work fine for most of the links, but fails for approximately 20 percent of them, where the link text is also removed. The most likely explanation is that my codes are wrong. So instead of this result:
<a href="cat2/3501-my-new-content-article"><a href="index.php?option=com_content&view=article&id=3501&catid=2">
My new article content</a></p>

I end up with this:
<a href="cat2/3501-my-new-content-article">My new content article</a> </p><a href="index.php?option=com_content&amp;view=article&amp;id=3501&amp;catid=2">

Which terms can I use for search and replacement to achieve the desired result?
Peter van Westen's Avatar Peter van Westen ADMIN
It is a bit beyond my support to fix your Regular Expressions for every replacement you do.
I recommend you learn more about Regular Expressions so you know what you are doing.

Instead of using (.*?), use this instead: ([^>]*)
Which will match all characters instead of the '>'.
Please post a rating at the Joomla! Extensions Directory
Buldre -'s Avatar Buldre -
A solution to the challenge would perhaps also be useful for other users of the forum.

Thanks for trying to help, even if it doesn't work.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription