ANUBHAV67 / vqmod

Automatically exported from code.google.com/p/vqmod
0 stars 0 forks source link

reference search result in add #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Is there a way to reference search result in add?  For example:

<search position="replace" regex="true"><![CDATA[
  /.*abc.*/
  ]]></search>

This would match the line "123abc456".  It would be nice if we can reference 
this result "123abc456" in the add tag.

Original issue reported on code.google.com by tri...@gmail.com on 19 Jun 2013 at 3:02

GoogleCodeExporter commented 9 years ago
This is for Issues not feature requests. Regardless, you can still reference 
the regex. Just put braces around it and reference it that way
/(.*abc.*)
then use
$1
in your add

Original comment by DJG6...@gmail.com on 19 Jun 2013 at 10:26

GoogleCodeExporter commented 9 years ago
Thanks for this tip but can you elaborate a little on how to use it?  I try the 
following and it doesn't work
      <search position="replace" regex="true"><![CDATA[
        /.*addToCart.*/
        ]]></search>
      <add><![CDATA[
          $1
        ]]></add>

Can I use $1 in php?  For example:
<?php
echo "$1";
echo str_replace("button", "button special", "$1");
?>

Thanks

Original comment by tri...@gmail.com on 20 Jun 2013 at 1:48

GoogleCodeExporter commented 9 years ago
The simplest way to find out.... try it!

Original comment by DJG6...@gmail.com on 20 Jun 2013 at 2:21

GoogleCodeExporter commented 9 years ago
I tried the following but doesn't work, it simply removes the entire line
that match addToCart

      <search position="replace" regex="true"><![CDATA[
        /.*addToCart.*/
        ]]></search>
      <add><![CDATA[
          $1
        ]]></add>

I tried it in php like this but doesn't work

<?php
echo "$1";
echo str_replace("button", "button special", "$1");
?>

Please give me some suggestion on how to format $1.  Is this in the wiki?
 I look through it but couldn't reference of $1 anywhere.

Original comment by tri...@gmail.com on 20 Jun 2013 at 2:27

GoogleCodeExporter commented 9 years ago
Notice the missing ( ) from your search compared to mine

Original comment by DJG6...@gmail.com on 20 Jun 2013 at 2:56

GoogleCodeExporter commented 9 years ago
Thank you.  That works.  Would you consider adding this to the wiki?  I
think it's useful to people.

Tri

Original comment by tri...@gmail.com on 20 Jun 2013 at 2:55