Status
Not open for further replies.

cvrle77

Active Member
5,787
2009
4,354
10
I have something in wordrpess posts (all of them) that I need removed:

something starting with this:

<!--more-->
<br />
<center>
<table width="100%">
<tbody>
<tr>

ending with this:

</td>
</tr>
</tbody>
</table>
</center>

part in the middle is changeable, usually containing some other piece of code.

I need regex to remove ALL from start to end, including start and end.
Anyone?
 
12 comments
C#

Code:
string my_needed_data = Regex.Match(complete_post, @"<tbody>\r\n<tr>[\r\n]+(.+?)</td>\r\n</tr>\r\n</tbody>", RegexOptions.Singleline).Groups[1].Value;
PHP

PHP:
if (preg_match('%<tbody>\r\n<tr>[\r\n]+(.+?)</td>\r\n</tr>\r\n</tbody>%s', $complete_post, $regs)) {
    $my_needed_data= $regs[1];
 
I need it to have included exact specified starting and ending points, because those are parts I want removed too.

It's a piece of code showing under each post, like advertisement. (done in a quite dumb way)

Basically, I would need only this: "<tbody>\r\n<tr>[\r\n]+(.+?)</td>\r\n</tr>\r\n</tbody>"
Like in notepad++
 
:/ seems we misunderstood each other. I need a regex code, that I will apply on my live website, and remove same text repeating in about 60000 posts.

I have a WP plugin that will do that for me.

So far: "<!--more-->\r\n<br\s/>\r\n<center>\r\n<table" this is good, but I need everything that shows after this point, to be found and matched, not sure which symbol is for that? (*) ??

For some reason, this won't remove everything to the bottom of the post, no idea why:

<!--more-->\r\n<br\s/>\r\n<center>\r\n<table+(.*)
 
PHP:
if (preg_match('%<tbody>\r\n<tr>[\r\n]+(.+?)</td>\r\n</tr>\r\n</tbody>%s', $complete_post, $regs)) {
    $my_needed_data= $regs[1]; // this is what u need then!
}


$regs[1] represent the 1st group match!


 
VCMQYie.png


This is how it looks in wordpress...
this particular one I have, stops on first page break, and doesn't capture EVERYTHING from that point, to the bottom of the post. (which is what I need)
 
Search pattern needs to start with <!--more-->\r\n<br\s/>\r\n blabla something to match EVERYTHING till the end of the post....

sorry for being so difficult :)
 
Thanks for leading me on right track, this is the code that I got, and works what I needed it for:

"<!--more-->\r\n<br\s/>\r\n<center>\r\n<table+[\s\S]*"
 
Status
Not open for further replies.
Back
Top