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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:48:09+00:00 2026-05-29T23:48:09+00:00

I know people often get told off here for using regexes to fiddle with

  • 0

I know people often get told off here for using regexes to fiddle with HTML which I understand but I think in this case I have a valid use for it to alter a CSS file. Unfortunately I am hopeless at writing them myself.

I’m writing a script (PHP) that needs to dynamically add/remove items in a CSS file. As an example the CSS file may have the following declaration:

.cat-item-4 {
    background: #ff0fcd;
}

Presumably a regex is possible to remove this whole declaration? It may contain other things asides from “background” so would need to spot the .cat-item-4 class and then remove both that and everything between and including the parentheses. The whole lot basically.

Any help 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-05-29T23:48:10+00:00Added an answer on May 29, 2026 at 11:48 pm

    You can use a regex find/replace with:

    $re = "#\.\bcat-item-4\b.+?\}#s";
    

    Coupled with the modifier PCRE_DOTALL (s), this will find all classes with the name bcat-item-4. The # signs tell PHP what delimiter to use, because after the second #, the ‘s’ indicates that the . should match newlines, which is essential in removing the entire declaration.

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

Sidebar

Related Questions

I'd like know what people think about using RAISERROR in stored procedures to pass
I think most people know how to do this via the GUI (right click
As I think most people know already, or if you don't, FPDF released a
I know that most people recommend using HttpRuntime.Cache because it has more flexibility... etc.
I know many people who use computers every day, who do not know how
Curious to know how people set up their personal and/or work development environment, in
I would like to know other people's opinion on the following style of writing
I'm not sure if many people know about this text-editor? jEdit was kinda big
I will choose Java as an example, most people know it, though every other
I use VIM editor for PHP, i know many people will point to PDT

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.