Closed drorsnir closed 2 years ago
I tried to see this live in action, but on this view it doesn't show me anything: https://www.kolzchut.org.il/he/Special:PageQuality/report?page_id=4497
Could you please share the link where I can find the HTML for the results?
So, I can recreate it using this revision: www.kolzchut.org.il/w/he/index.php?title=הפסקת_היריון&action=edit&oldid=454915
Now, it's actually very simple (but took me over an hour to debug):
<b></b>
- another 8 characters. This should work perfectly, only the expression shows twice - 8 characters too many.so you end up with this:
להפסיק את ה<b>הריון</b>. סעיף 316 לחוק העונשין מפרט את המקרים שבהם יש לוועדה סמכות לאשר הפסקת <b>הריון</b>
להפסיק את ה<b>הריון</b>. סעיף 316 לחוק העונשין מפרט את המקרים שבהם יש לוועדה סמכות לאשר הפסקת <b>הר
<b>
tag...The simplest solution is to use substr_replace() instead of str_replace(), and replace only the 1st occurrence of the expression.
(And while you're at it, could you remove the trim( $blocked_expression )
? Many times we need to add a space before and/or after the expression, so that it won't be considered a match in the middle of another word.)
I don't fully understand this. But do you think just adding str_replace with count 1 should solve the problem?
Here's the function definition:
str_replace( array|string $search, array|string $replace, string|array $subject, int &$count = null ): string|array
Count doesn't do what you think it does:
If passed, this will be set to the number of replacements performed
So it doesn't limit the number of replacements. Otherwise, this would be perfect. Use whatever you need to make sure only a single replacement is performed.
Seems to work well :-)
See the following two screenshots, from this page: https://www.kolzchut.org.il/he/הפסקת_הריון
It starts out OK, but then we suddently have whole examples in bold. It looks like maybe you add the
<b>
tags and then cut the string, causing the tags to flow over.