Converting image tags [img=url] to [img]url[/img]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trhoppe
    New Member
    • Aug 2008
    • 8

    Converting image tags [img=url] to [img]url[/img]

    From reading, sounds like cleaner.php is my best solution, but what exactly is the regular expression that I need to run inside of cleaner to conver [img=urlGoesHere] to [img]urlGoesHere[/img]

    Thanks!
  • Jerry
    Senior Member
    • Dec 2002
    • 9137
    • 1.1.x

    #2
    This should help, the img regex there should do what you're after :

    I wrote ImpEx.

    Blog | Me

    Comment

    • trhoppe
      New Member
      • Aug 2008
      • 8

      #3
      Originally posted by Jerry
      This should help, the img regex there should do what you're after :

      http://www.vbulletin.com/forum/showthread.php?t=282129
      That doesn't quite get what I needed.

      The url of the image is INSIDE the [img=] so it looks like [img=http://imagepathhere]

      I need to grab that image path and put it into regular [img][/img] tags.

      -Tom

      Comment

      • dave683
        New Member
        • Aug 2008
        • 5

        #4
        Originally posted by trhoppe
        That doesn't quite get what I needed.

        The url of the image is INSIDE the [img=] so it looks like [img=http://imagepathhere]

        I need to grab that image path and put it into regular [img][/img] tags.

        -Tom
        Try that. Back up ur data first XD

        PHP Code:
        $text preg_replace('#\[img=(.*)\]#siU''[img]$1[/img]' ,$text); 

        Comment

        • Jerry
          Senior Member
          • Dec 2002
          • 9137
          • 1.1.x

          #5
          Which would be :

          PHP Code:
          $text preg_replace('#\[img=(.*)\](.*)\[/img]#siU''[img]$1[/img]'$text); 
          I wrote ImpEx.

          Blog | Me

          Comment

          • Jerry
            Senior Member
            • Dec 2002
            • 9137
            • 1.1.x

            #6
            Originally posted by dave683
            Try that. Back up ur data first XD

            PHP Code:
            $text preg_replace('#\[img=(.*)\]#siU''[img]$1[/img]' ,$text); 
            Close, though that won't clean out what is in between the tags and match-to-replace the origional closing one.
            I wrote ImpEx.

            Blog | Me

            Comment

            • trhoppe
              New Member
              • Aug 2008
              • 8

              #7
              Originally posted by Jerry
              Close, though that won't clean out what is in between the tags and match-to-replace the origional closing one.
              Actually $text = preg_replace('#\[img=(.*)\]#siU', '[img]$1[/img]', $text); was it

              I now understand a bit more about reg exps but I still have no idea what "$1" is in the replacement and how that works.

              The other one which had preg_replace('#\[img=(.*)\](.*)\[/img]#siU' never matched as the dumb megaBBS board never had closing img tags.

              Jerry, thanks for all the help with the import, this thread and the others that you answered had great advice and help!

              dave683, thanks for the help with that statement

              -Tom

              Comment

              • Jerry
                Senior Member
                • Dec 2002
                • 9137
                • 1.1.x

                #8
                Ah yes, my bad, I didn't read it fully and missed that there was no closing [/img] tag ..... !
                I wrote ImpEx.

                Blog | Me

                Comment

                • dave683
                  New Member
                  • Aug 2008
                  • 5

                  #9

                  .
                  .
                  .

                  Comment

                  widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                  Working...
                  😀
                  😂
                  🥰
                  😘
                  🤢
                  😎
                  😞
                  😡
                  👍
                  👎