ABHISHEKARYA131 / vqmod

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

Before/After Only on new lines #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Apologies if this isn't a bug and working as expected

On before/after searches eg 

String: "I want something green"

<search regex="true" position="after"><![CDATA[/something/i]]></search>
<add><![CDATA[ blue and]]></add>

Will output:
I want something green
 blue and

Not "I want something blue and green". I appreciate you can use replace, but 
this isn't possible with more complex code using regex where you can only be 
sure of a few things.

I tried adding an offset of 0 but without success.

vQmod Version: 2.1.6
Server Operating System: Unix with Apache

Original issue reported on code.google.com by blacka...@gmail.com on 13 Apr 2012 at 5:38

GoogleCodeExporter commented 9 years ago
That is how it's meant to work. AFTER and BEFORE put content on a new line 
BEFORE/AFTER the match. What you need to use is replace. Note in the replace, 
you would need to use 
<add><![CDATA[something blue and]]></add>

Original comment by DJG6...@gmail.com on 13 Apr 2012 at 5:40

GoogleCodeExporter commented 9 years ago
Linux even haha

Original comment by blacka...@gmail.com on 13 Apr 2012 at 5:42

GoogleCodeExporter commented 9 years ago
Ok Thankyou. Feature request perhaps?

Original comment by blacka...@gmail.com on 13 Apr 2012 at 5:46

GoogleCodeExporter commented 9 years ago
I don't really see how that would be more beneficial? It will add more overhead 
for a feature that already does it just fine

Original comment by DJG6...@gmail.com on 13 Apr 2012 at 5:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Lets say the line:

<div class="image"><a href="<?php echo $popup; ?>" title="<?php echo 
$heading_title; ?>" class="colorbox" rel="colorbox"><img src="<?php echo 
$thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo 
$heading_title; ?>" id="image" /></a></div>

Maybe not the best example especially after writing... I want to say add an 
additional class to the link element. I'm happy that $popup is going to be 
always there, followed by anything (perhaps a theme added an alt or something, 
or the class before the title). So the search is /\$popup.*?class="/i to match 
the first class after popup. I then want to add additional classes with the 
after function. I don't want to replace with new code in case I change 
something with the theme.

Original comment by blacka...@gmail.com on 13 Apr 2012 at 5:58

GoogleCodeExporter commented 9 years ago
Of course, you could just simplify, use

<search regex="true" 
position="after"><![CDATA[/(\$popup.*?class=")/i]]></search>
<add><![CDATA[$1newClass ]]></add>

Which would do the same thing, and not require adding the functionality

Original comment by DJG6...@gmail.com on 13 Apr 2012 at 6:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
should be "replace" above not "after" in the position

Original comment by DJG6...@gmail.com on 13 Apr 2012 at 6:06

GoogleCodeExporter commented 9 years ago
That would just output

<div class="image"><a href="<?php echo $popup; ?>" title="<?php echo 
$heading_title; ?>" class="colorbox" rel="colorbox"><img src="<?php echo 
$thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo 
$heading_title; ?>" id="image" /></a></div>
$lnewClass

Where it would be beneficial to have
<div class="image"><a href="<?php echo $popup; ?>" title="<?php echo 
$heading_title; ?>" class="$lnewclass colorbox" rel="colorbox"><img src="<?php 
echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo 
$heading_title; ?>" id="image" /></a></div>

Original comment by blacka...@gmail.com on 13 Apr 2012 at 6:06

GoogleCodeExporter commented 9 years ago
sorry corrected a typo there and you had already replied.

Confused about how that would work, as I don't know what the vqmod regex found 
in order to insert it back into the variable

Original comment by blacka...@gmail.com on 13 Apr 2012 at 6:08

GoogleCodeExporter commented 9 years ago
it will add back everything the regex matches, since the "replace" is identical 
to the preg_replace function when position="replace" and regex="true"

Original comment by DJG6...@gmail.com on 13 Apr 2012 at 6:09

GoogleCodeExporter commented 9 years ago
Ah i'm being a muppet here and reading that as a L not 1, didn't even think it 
would return anything in vqmod like preg_replace. Thanks for the time

Original comment by blacka...@gmail.com on 13 Apr 2012 at 6:14