Search
Other DB Replacer questions
Forum

Regex Search Problem

Kai Ewers's Avatar Kai Ewers
Hello Peter,

I've been trying to use Regex to replace some links on our website and have run into the issue: "The database query is invalid. Try changing the search."

If doing a non-regex search for the text to replace in table 'conten' column 'intro text' (or 'full text') the links get found — but not with the Regex (which as some other posters encountered, might be a server / my SQL configuration issue?).

I've validated the Regex on regexr.com:

Search:
<p style="text-align: (left|right|center);">  
  <a href="\/terminsuche\.html(?:#\w+)?"  
     class="el-content uk-button uk-button-secondary uk-button-large uk-flex-inline uk-flex-center uk-flex-middle">  
    <span class="uk-margin-small-right uk-icon" uk-icon="calendar"><\/span>  
    (.*?)  
  <\/a>  
<\/p>

Replace with:
<aside>  
    <p style="text-align: left;">  
        <a href="/terminsuche.html\2"  
           class="el-content uk-button uk-button-secondary uk-button-large uk-flex-inline uk-flex-center uk-flex-middle"  
           rel="nofollow">  
            <span class="uk-margin-small-right uk-icon" uk-icon="calendar"></span>\3  
        </a>  
    </p>  
</aside>

Could you lend some help on why this isn't working out?

Thanks in advance
Peter van Westen's Avatar Peter van Westen ADMIN
It is probably down to (?:#\w+)

You are referencing it with \2. But the '?: says you do not want to capture it.
So try:
<a href="\/terminsuche\.html((?:\#\w+)?)"
or:
<a href="\/terminsuche\.html((?:\#[^"]+)?)"
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription