These are chat archives for collectiveaccess/support

Dec 2017
Dec 20 2017 10:02

Hi! I need some help using php preg_replace with attributes in pawtucket2. For instance I’d like to change the LCSH ID to a URL.


<unit relativeTo="" delimiter="<li>"><a href="^">^ca_objects.lcsh_terms.text</a></unit>

gets me info:lc/authorities/names/n86705923. Using preg_replace I wish I could change this to The following code however does not work:

    $str = '^';
    $re = '/info:lc/';
    $subst = '';
    $result = preg_replace($re, $subst, "$str");
    echo "The result of the substitution is ".$result;

The output is:

The result of the substitution is info:lc/authorities/names/n86705923

What am I missing here? It is like the $str is not handled as a string…

Dec 20 2017 18:39
I'm having an issue that often but not always, when I try to save search tools, metadata elements in the manage menu or create entities from the quick add , the user is logged out, and all the information is gone when logged back in. This can happen several times in a row.
Mike Benowitz
Dec 20 2017 18:52
@ca-ubos your third argument to preg_replace doesn't need to be in quotes. You could also use str_replace if you'll always be replacing "info:lc". It takes the same arguements: str_replace('info:lc', '', $str)