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 5974803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:59:35+00:00 2026-05-22T20:59:35+00:00

Possible Duplicate: replace all “foo” between () Hello, I tried to use regex to

  • 0

Possible Duplicate:
replace all “foo” between ()

Hello,

I tried to use regex to replace all foo string between the () which between style=" and "

Here’s an example :

blah blah foo blah style="foo text blah (foo and blah foo)"

it should be replaced to be :

blah blah foo blah style="foo text blah (bar and blah bar)"

i tried to use this code but it dont working .

do {
  $code = preg_replace('/(style\=\"[^)]*)left(?=[^()]*\))([^)]*\")/U', '\1tempvalue\3', $code, -1, $count);
} while($count != 0);

then im trying to using foreach to get the results,, then replace it normally using preg_replace .

i wish to find the answer 🙂 ,, thank you.

  • 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-22T20:59:35+00:00Added an answer on May 22, 2026 at 8:59 pm

    Works on your string, might need modifying a bit to work in all circumstances…

    echo preg_replace_callback('/style="(.*)(\(.+\))"/',create_function(
       '$matches',
        'return "style=\"" . $matches[1] . preg_replace("/foo/","bar",$matches[2]) . "\"";'
    ),'blah blah foo blah style="foo text blah (foo and blah foo)"');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Weird “406 not acceptable” error I've been stuck on this ALL DAY!
Possible Duplicate: Eclipse Replace text in all Classes? I want to replace all instances
Possible Duplicate: Java Regex Replace with Capturing Group Is there any way to replace
Possible Duplicate: Regex to change format of all img src attributes Hi, I want
Possible Duplicate: PHP: Strip a specific tag from HTML string? Hi All, I want
Possible Duplicate: PHP: Replace umlauts with closest 7-bit ASCII equivalent in an UTF-8 string
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: Make iPhone app paid version replace free version on install from app

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.