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

  • SEARCH
  • Home
  • 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 6075795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:32:04+00:00 2026-05-23T10:32:04+00:00

I have a bunch of html string.(Raw String) Lorem ipsum dolor sit amet, consectetur

  • 0

I have a bunch of html string.(Raw String)

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Cras a egestas lacus. Praesent non ante in dui pellentesque 
molestie. Fusce facilisis, libero eu pellentesque varius, 
est magna pretium urna, id dictum urna tortor eget neque. 
Sed a arcu a lectus euismod volutpat. Aenean est urna, 
ultricies quis consequat sit amet, pretium a massa. 
Praesent sit amet nisl nec dolor malesuada posuere. 
Phasellus ac urna eget ligula vehicula cursus. Donec
 volutpat dui egestas dolor aliquet interdum. Vestibulum 
 ante ipsum primis in faucibus orci luctus et ultrices 
 posuere cubilia Curae; Duis sed neque sed mauris gravida 
 rhoncus. 
 <ul class="image-info">
    <li id="ID5555-1" class="image-size"></li>
    <li id="ID5555-2" class="image-height"></li>
    <li id="ID5555-3" class="image-width"></li>
</ul>
<div id="ID5555-4"  class="file-preview"></div>
<div id="ID5555-5"  class="file-detail"></div>

Cum sociis natoque penatibus et magnis dis parturient montes, 
nascetur ridiculus mus. Nam eu egestas ipsum. Duis ultrices 
vehicula metus, sit amet convallis libero suscipit ac.

<ul class="image-info">
    <li id="ID7777-1" class="image-size"></li>
    <li id="ID7777-2" class="image-height"></li>
    <li id="ID7777-3" class="image-width"></li>
</ul>
<div id="ID7777-4"  class="file-preview"></div>
<div id="ID7777-5"  class="file-detail"></div>

 Nullam libero lorem, suscipit in imperdiet ac, porttitor sit amet turpis.
 Cras tincidunt imperdiet eros, id sagittis felis pellentesque sit amet. 
 Mauris ultrices nulla ac dolor fermentum at feugiat erat egestas. Quisque 
 dapibus tellus eu dolor sagittis consequat. Maecenas dapibus dolor et nunc 
 sollicitudin laoreet. Sed lacus est, pharetra a fringilla eu, ornare varius 
 lacus. Etiam at lorem in leo molestie interdum ut vitae diam. Morbi semper 
 velit vitae elit ullamcorper id rutrum 

<ul class="image-info">
    <li id="ID9999-1" class="image-size"></li>
    <li id="ID9999-2" class="image-height"></li>
    <li id="ID9999-3" class="image-width"></li>
</ul>
<div id="ID9999-4"  class="file-preview"></div>
<div id="ID9999-5"  class="file-detail"></div>

In venenatis elementum mauris, 
at auctor nulla cursus ac. Duis accumsan nisi ut 
eros euismod vehicula. Duis luctus dui eget nibh 
tempus lacinia tristique libero imperdiet. 
Sed tristique pulvinar suscipit. 

Through php script, I want to find a string pattern
and replace it with some other string.

below you can see the string pattern.
and you can find it 3 times in the original raw string.

<ul class="image-info">
    <li id="unique-name1" class="image-size"></li>
    <li id="unique-name2" class="image-height"></li>
    <li id="unique-name3" class="image-width"></li>
</ul>
<div id="unique-name4"  class="file-preview"></div>
<div id="unique-name5"  class="file-detail"></div>

in the raw string, there are lots of this pattern strings.
and “unique-name” is identification id of the pattern, unique, ex)ID23291
and this is replacement string

<div id="unique--name" class="raw-image-info"></div>

so, the final string should be like this~

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Cras a egestas lacus. Praesent non ante in dui pellentesque 
molestie. Fusce facilisis, libero eu pellentesque varius, 
est magna pretium urna, id dictum urna tortor eget neque. 
Sed a arcu a lectus euismod volutpat. Aenean est urna, 
ultricies quis consequat sit amet, pretium a massa. 
Praesent sit amet nisl nec dolor malesuada posuere. 
Phasellus ac urna eget ligula vehicula cursus. Donec
 volutpat dui egestas dolor aliquet interdum. Vestibulum 
 ante ipsum primis in faucibus orci luctus et ultrices 
 posuere cubilia Curae; Duis sed neque sed mauris gravida 
 rhoncus. 
<div id="ID5555" class="raw-image-info"></div>    
Cum sociis natoque penatibus et magnis dis parturient montes, 
nascetur ridiculus mus. Nam eu egestas ipsum. Duis ultrices 
vehicula metus, sit amet convallis libero suscipit ac.

<div id="ID7777" class="raw-image-info"></div>    

 Nullam libero lorem, suscipit in imperdiet ac, porttitor sit amet turpis.
 Cras tincidunt imperdiet eros, id sagittis felis pellentesque sit amet. 
 Mauris ultrices nulla ac dolor fermentum at feugiat erat egestas. Quisque 
 dapibus tellus eu dolor sagittis consequat. Maecenas dapibus dolor et nunc 
 sollicitudin laoreet. Sed lacus est, pharetra a fringilla eu, ornare varius 
 lacus. Etiam at lorem in leo molestie interdum ut vitae diam. Morbi semper 
 velit vitae elit ullamcorper id rutrum 

<div id="ID9999" class="raw-image-info"></div>    

In venenatis elementum mauris, 
at auctor nulla cursus ac. Duis accumsan nisi ut 
eros euismod vehicula. Duis luctus dui eget nibh 
tempus lacinia tristique libero imperdiet. 
Sed tristique pulvinar suscipit. 

I think it’s a little bit complicate. regex and preg_replace is the way?
Do I have to find another way to do this work?

  • 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-05-23T10:32:05+00:00Added an answer on May 23, 2026 at 10:32 am

    At last, I find a solution of this problem.
    My solution is not using php, using jquery.
    Process it in client, not server.

    the code is like this,

    $(document).ready(function(){
        $("ul.image-info").each(function(){
            $(this).replaceWith('');
        });
        $("div.file-preview").each(function(){
            $(this).replaceWith('<div class="raw-image-info" id="' + 
              $(this).attr("id").substring(0, $(this).attr("id")-1) + '"></div>');
        });
        $("div.file-detail").each(function(){
            $(this).replaceWith('');
        });
    });
    

    Hope this help for another guys who confront this kind of problem too.

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

Sidebar

Related Questions

i have a string that contains a bunch of html. i want to html-encode
I have a bunch of html with lines like this: <a href=# rel=this is
We have bunch of Domain Entities which should be rendered to an html format,
I have a bunch of these little bits of HTML code repeated over and
I have a bunch of forms where its easier to type the entire html
I have a web application with bunch of HTML code. There are some style-attributes
We have an HTML page which displays a bunch of pretty bars using divs
so I have this HTML table with a bunch of big numbers in it
I have html code like this <tr class=odd> <td><b>Reason for Termination:</b></td> <td>this has bunch
ok, so i have this slideshow.html containing just a bunch of pictures, and the

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.