Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7813549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:54:33+00:00 2026-06-02T04:54:33+00:00

I am writing a message board that allows for quoting and quote chaining of

  • 0

I am writing a message board that allows for quoting and quote chaining of other users. The message board allows certain html tags including the <img>. When a message is quoted, I want to find the <img> and replace the picture with a thumbnail. Here is my current code:

<?php
 $pattern = "<quote msgid=\"t,(\d+),(\d+)@(\d+)\" from=\"([A-z0-9_\.-]+)\" posted=\"(\d+)\">(.+)<img src=\"https?:\/\/i\.(minus|imgur)\.com\/([A-z0-9_\.-]+)\.(jpg|gif|png|jpeg)\"( \/)?>";
 $replace = "<div class=\"quoted-message\" msgid=\"t,$1,$2@$3\"><div class=\"message-top\">From: $4 | Posted: $5</div>$6<img src=\"http:\/\/$7.com\/$8s\.$9\" />";
 $encoded = preg_replace($pattern, $replace, $encoded);
?>

The pattern itself works but the problem I am running into is that it does not play nice with nested quotes. For example the data can look like this:

<quote msgid="t,1234,3456@0" from"user" posted="test">Some words here<quote msgid="t,5635,57456@0" from"user2" posted="test">Some more <b>words</b> here<quote msgid="t,1243532,3452@0" from"user" posted="test">Something else here<img src="linktoimage"/></quote>some words can go here</quote>or here</quote>

My current regex will replace the first 3 Opening quote tags with one div tag instead of just matching the most inner tag. I know it has to do with the (.+) but I don’t know what else I can do in order to check for preceding data.

Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:54:37+00:00Added an answer on June 2, 2026 at 4:54 am

    Regular expressions are not very suitable for your situation (very oddly explained here). You should really use a parser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a message processing application (email) that I want to have an outgoing
I'm writing an application that takes HTML pages and parses them to display on
I writing a console app that add a message to local queue. But, no
I am writing a program which makes a RPC to print a message that
I am interested in writing an app that will intercept an outgoing SMS message
I am writing a message transfer program between multiple clients and server. I want
So I am writing a simple inbox private message system. My table schema is
I am writing a usenet newsreader, and calling the XOVER id- message to get
I'm writing a WinForms application that sends email messages (like a mail merge). I'd
I am writing a process that will run continuously, getting messages on a queue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.