Welcome Guest, Not a member yet? Register   Sign In
pre_replace not sure what the correct expression is

this might help. i renamed the word_censor function (as it was posted in the linked thread) to regex_mill()

i believe that this demonstrates almost perfectly what you are looking for:
$s = 'this is a <a href="string">string</a> with text/texts and HTML anchor and img tags (img tag here: <img src="">) mixed in. this is a string without a tag.';
$lookfor = array('(\s)(string)(\s)', 'texts?', 'HTML anchor', '[^<](img)');
$replacements = array('$2<a href="tags/$3">$3</a>$4','<a href="tags/$1">$1</a>','<a href="tags/$1">$1</a>','<a href="tags/$2">$2</a>');

$out = regex_mill($s, $lookfor, $replacements, 'i');

to understand and use this regex_mill you are going to have to learn some regex to "tune" what the patterns find and what they are replaced with, but this should get you going with the basics.

happy birthday!

Thank you so much,

I'll give it a go and see what i'll come upi

your a star this is working great so far.

Hi I've got it working with single words but when i come across a multiple words it stops working.

I've been reading that regex ref site you linked me too which great.

i think it regex to stop a string with multiple words appearing in a link would be

[^<](wordone wordtwo)

But it stops working completely.

it depends which part of the "link" you are referring to. the href attribute or the display text that shows in between the open and close "a" tags?

which one of these:
<a href="this/is/a/path/and/shouldnothavespaces">display text with spaces</a>

if it is the display text, you just need to turn your less-than into a greater-than:

[^>](wordone wordtwo)

note: this assumes no space between the greater-than sign and the string "wordone".


Once again your a star.

Cheers for that

Theme © iAndrew 2016 - Forum software by © MyBB