Announcement

Collapse
No announcement yet.

deleteing from text table

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Those [FONT], [SIZE] and [COLOR] BBCode tags will be replaced with their corresponding HTML tags when displayed in the posts. The CSS solution I posted should still work in resetting those styles to default/inherited style.

    But if you insist on doing the SQL solution over CSS solution, you'll likely need to use REGEXP_REPLACE() which is not simple to do.

    Buy me a coffeePayPal QR Code
    My Amazon Affiliate Link
    Fast vBulletin VPS Host:
    This site is hosted by IONOS

    Comment


      #17
      this's as you said.

      Click image for larger version

Name:	image.png
Views:	193
Size:	15.7 KB
ID:	27818
      And here's the result in the post (Sorry it's arabic language
      Click image for larger version

Name:	image.png
Views:	178
Size:	25.0 KB
ID:	27819

      Is this correct?

      UPDATE `text` SET `rawtext` = REGEXP_REPLACE(`rawtext`, '\\[font=[a-zA-Z0-9 ]+\\]', '')

      UPDATE `text`SET `rawtext` = REGEXP_REPLACE(`rawtext`, '\\[color=#[a-fA-F0-9]{6}]\\]','');
      ​​

      Comment


        #18
        It looks like the [color] BBCode tags are not evaluated to its <font> HTML equivalent with color attribute. The CSS will not be applied in that case as it only works with HTML tags not BBCode tags.

        I notice that the [color] BBCode tags are invalid/incorrect. Was it caused of the SQL Update query you executed?
        Buy me a coffeePayPal QR Code
        My Amazon Affiliate Link
        Fast vBulletin VPS Host:
        This site is hosted by IONOS

        Comment


          #19
          This's why I decided to remove any old tag there, even if manually.

          Regards.
          .

          Comment


            #20
            I'm not an expert in regular expressions but try doing a SELECT first and see if any records match and then use the pattern in the UPDATE later.

            Code:
            SELECT * FROM text WHERE rawtext REGEXP '\\[font .+\\]';
            This is a safer way to test the REGEXP pattern first without doing the UPDATE yet.
            Buy me a coffeePayPal QR Code
            My Amazon Affiliate Link
            Fast vBulletin VPS Host:
            This site is hosted by IONOS

            Comment


              #21
              Example:
              [FONT=Simplified Arabic] = 90 matches


              Here's the result​


              Click image for larger version

Name:	image.png
Views:	124
Size:	7.1 KB
ID:	27828

              Comment


                #22
                Try this:

                Code:
                SELECT * FROM text WHERE rawtext REGEXP '\\[font\\s|font\=.+\\]';​


                This should cover both [FONT COLOR=XXXXXX] and [FONT=XXXX]
                Buy me a coffeePayPal QR Code
                My Amazon Affiliate Link
                Fast vBulletin VPS Host:
                This site is hosted by IONOS

                Comment


                  #23
                  Btw, I'm not responsible if your data gets messed up with the solutions I'm posting. I recommend doing this in a copy of the database rather than the live database.
                  Buy me a coffeePayPal QR Code
                  My Amazon Affiliate Link
                  Fast vBulletin VPS Host:
                  This site is hosted by IONOS

                  Comment


                    #24
                    I updated the REGEXP pattern used. See it in the query below.

                    I also updated the SELECT query to show the preview of the updated rawtext so you can see if the replacements to be done look good.
                    Code:
                    SELECT rawtext as `rawtext before`, REGEXP_REPLACE(rawtext, '\\[font\\s.+\\]|\\[font\=.+\\]', '') as `rawtext after` FROM text WHERE rawtext REGEXP '\\[font\\s.+\\]|\\[font\=.+\\]';
                    Buy me a coffeePayPal QR Code
                    My Amazon Affiliate Link
                    Fast vBulletin VPS Host:
                    This site is hosted by IONOS

                    Comment


                      #25
                      Originally posted by glennrocksvb View Post
                      I updated the REGEXP pattern used. See it in the query below.

                      I also updated the SELECT query to show the preview of the updated rawtext so you can see if the replacements to be done look good.
                      Code:
                      SELECT rawtext as `rawtext before`, REGEXP_REPLACE(rawtext, '\\[font\\s.+\\]|\\[font\=.+\\]', '') as `rawtext after` FROM text WHERE rawtext REGEXP '\\[font\\s.+\\]|\\[font\=.+\\]';
                      See sample results from my test database:

                      Click image for larger version

Name:	image.png
Views:	137
Size:	120.5 KB
ID:	27834
                      Buy me a coffeePayPal QR Code
                      My Amazon Affiliate Link
                      Fast vBulletin VPS Host:
                      This site is hosted by IONOS

                      Comment


                      • glennrocksvb
                        commented
                        Editing a comment
                        Oopps! There's a bug in the query. It also deletes the text between the [FONT] tags.
                        Last edited by glennrocksvb; 09-26-2023, 03:00 PM.

                      • glennrocksvb
                        commented
                        Editing a comment
                        This is complicated to fix. It would require a lot of trials and errors. There are a lot of BBCode variations to cover. You need to find the different variations used in the database so you can limit/simplify the REGEXP patterns to use in the query and not try to cover all possible variations.

                      #26
                      Originally posted by glennrocksvb View Post
                      Try this:

                      Code:
                      SELECT * FROM text WHERE rawtext REGEXP '\\[font\\s|font\=.+\\]';​


                      This should cover both [FONT COLOR=XXXXXX] and [FONT=XXXX]
                      Here's the result

                      Click image for larger version

Name:	image.png
Views:	138
Size:	6.9 KB
ID:	27848

                      Comment


                        #27
                        Originally posted by glennrocksvb View Post

                        See sample results from my test database:

                        Click image for larger version  Name:	image.png Views:	6 Size:	120.5 KB ID:	27834
                        This one says:
                        Click image for larger version

Name:	image.png
Views:	136
Size:	6.8 KB
ID:	27850

                        First total is 15544
                        Second is 4041​

                        Comment


                          #28
                          The SELECT query I provided has a bug in it as I mentioned in the comments in post #25
                          Buy me a coffeePayPal QR Code
                          My Amazon Affiliate Link
                          Fast vBulletin VPS Host:
                          This site is hosted by IONOS

                          Comment


                            #29
                            Originally posted by abd View Post
                            This's why I decided to remove any old tag there, even if manually.
                            Regards.
                            .
                            Why removing, you would corrupt your form styling, i used to do this in very simple way, and it just takes a few seconds for thousands of fields to be replaced.

                            update text set rawtext =
                            replace(rawtext,'=12px','18px');​

                            Comment

                            Latest Posts

                            Collapse

                            Working...
                            X
                            Searching...Please wait.
                            An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

                            Please push the back button and reload the previous window.'
                            An unexpected error was returned: 'Your submission could not be processed because the token has expired.

                            Please push the back button and reload the previous window.'
                            An internal error has occurred and the module cannot be displayed.
                            There are no results that meet this criteria.
                            Search Result for "|||"