in Education by
We are in the process to update an existing WordPress website and imported posts from one site to another. On the old website we used a WYSIWYG editer and all the posts have styles embedded in them Example:

Content

Expected output:

Content

Now I'm looking for a way to remove the style tag from the html elements. Self I was thinking about an MySQL query but have trouble to figuring out how to preg_replace in it. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
If you want to perform the migration on database level, I would recommend to add a new column to your post table so you can first create a copy of your old data and then compare the results of a migration script. After adding the new column, you could use REGEXP_REPLACE as part of an UPDATE to copy the data into the new column. You may have to change the regular expression syntax so it catches all characters you encounter in the "style" section but this could be a start: UPDATE post_table SET stripped_text = regexp_replace(original_text, ' style="[[:alnum:][:digit:][:space:];,:\(\)\'\-\.]+"', '') Examine the data and see if the results are OK, repeat until the result is good enough. Rename your original post column ("original_text" in my sample) to something like "orignal_backup" and your new column ("stripped_text" in my example) to the original post column's name. More information regarding character classes in MySQL REGEX can be found here.

Related questions

0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    The tables are: 1) Producers: id, name 2) Products: id, name, price, category_id, producer_id 3) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    Im trying to insert the current date and a specific time into a table this is my query INSERT INTO ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Im trying to insert the current date and a specific time into a table this is my query INSERT INTO ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I got that table : id, user_a, user_b, score 1, 3, 7, 19 2, 8, 3, 20 3, 3, ... JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I got that table : id, user_a, user_b, score 1, 3, 7, 19 2, 8, 3, 20 3, 3, ... JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    Hi I have two tables here: Transcript Grade Student_number Course_number Semester Year A 8 MATH2410 Fall 07 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    Hi I have two tables here: Transcript Grade Student_number Course_number Semester Year A 8 MATH2410 Fall 07 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I've extracted certain elements from a HTML page with beautifulsoup and want to extract the according CSS ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 3, 2022 in Education by JackTerrance
0 votes
    How can i replace a string that contain symbol to a class css? HTML JQUERY p= '@.class-two'; $( ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    How can I replace a specific text with HTML objects? example: var text = "some text to replace ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    How can I replace a specific text with HTML objects? example: var text = "some text to replace ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
...