Regular expression for finding CSS key-value pairs

Currently, I am utilizing regular expressions to identify CSS values.

The input string that needs to be matched is:

 font-size:25px;font-family:georgian;content:"' unicode given in pseudo © '";

The specific regex pattern I am using for the matching process is:

/.*\bcontent:(\s*[^;]*)/

I am retrieving the actual string output of the regex by using $1.

The expected output should be "' unicode given in pseudo &#169 '".**

However, the current output is "' unicode given in pseudo &#169

This discrepancy occurs because the regex detects the semicolon inside the content value and breaks there. To resolve this bug, I need the regex to locate the last semicolon that is not within the quotes. The reason for this is that each property value in my input string will always end with a semicolon.

Thank you!

Answer №1

Make it easier: Grab the text section enclosed within quotation marks:

/.*\bcontent:(\"[^\"]*\")/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What might be causing the invisibility of a particular div element?

Here is the layout in the div element: <div class=" wrap clear"> <div class="block pink float"></div> <div class="block blue float"></div> <div class="block orange float"& ...

Dealing with the Spread operator in React and Redux causes issues

As a newcomer to the world of React and Redux, I find myself facing compilation errors while working on a reducer due to my attempt to utilize the spread operator. export default function chaptersReducer( state = { chapters: {}, isFetching: false, error ...

What factors contribute to a one-hour discrepancy between two time stamps, deviating from the anticipated value?

Let's consider the dates '2022-04-01' and '2022-05-15'. When I calculated their deviation using Chrome devtools, here are the results: https://i.stack.imgur.com/tSZvk.png The calculated result is 3801600000. However, when my frie ...

A Fresh Approach for Generating Unique UUIDs without Bitwise Operators

To generate UUIDs in TypeScript, I have implemented a method inspired by the solution provided on Stack Overflow. The code effectively converts JavaScript to TypeScript. generateUUID(): string { let date = new Date().getTime(); if (window.performa ...

Anchors that need to be clicked multiple times before activating

'I recently encountered a strange bug. My CSS3 anchors/buttons, which I have been simplifying by removing properties, sometimes require multiple clicks to function. This is completely new to me and quite perplexing. The issue seems to occur randomly, ...

Avoid the simplified view prompt when using Chrome or utilize the simplified view feature without any interruptions

When I access my website from Chrome on Android, I am prompted to "Show Simplified View" at the bottom of the screen. Clicking this prompt results in only one news item being displayed instead of the intended 25, controls removed, and scrolling disabled. O ...

Can node.js be used to extract slides from PowerPoint and convert them into images?

We are currently in the process of creating a new application that utilizes sailsjs (node + mongo) as its backend system. Our client has requested a specific feature where users can upload *.ppt files and potentially extract all slides to save them as ima ...

Navigating pages in tinymce editor

Currently, I have implemented TinyMCE as the editor for my PHP-based website. However, I am facing a challenge in integrating pagination within the editor. My goal is to allow users to input long content that will be displayed across multiple pages inste ...

Is there a way to send a boolean to a directive and activate a function when that boolean is altered, all without using $watch?

My goal was to achieve something akin to the following simplified example: class ButtonController { set isFoo(value) { console.log(value); // do something here } } angular.module('myApp', []).directive('mButton', () => ...

developing a durable data hook with function support

As I work on developing a new hook to persist filter state, I encounter a challenge with some of the filters containing complex objects like dates which may include functions. The goal is to be able to store and retrieve these functions from local storage ...

How to properly load components in React?

I've been diving into building a simple app in React using ES6 and Babel. While working on it, I encountered an issue. I decided to incorporate the react-notifications package from https://github.com/minhtranite/react-notifications Following the docu ...

Numerous Radio Buttons

I am currently working on creating a quiz similar to those found on Buzzfeed and Zimbio. I apologize if this question has been asked before, but despite my efforts in searching, I have not been able to find the answer I am looking for. In this quiz, partic ...

Troubleshooting: Next JS 13/14 - Server component failing to update data upon revisiting without requiring a refresh

After attempting to retrieve the most recent liked items from a server component in next, I noticed that the data only displays when manually refreshing the page. Even when I navigate away and return, the data is not refetched automatically - however, usin ...

What is the best way to utilize the "map" function in React to convert an array of objects into a different array of objects?

I need some help with React version 16.10.0. How can I change my array into a new array of objects? My original array consists of objects with the following attributes id name But now, I want to create a new array that contains objects with these attribu ...

What is the best way to activate multiple events within an overlapping area containing multiple divs at the same

How can I trigger events on same level divs that overlap in different areas? When there are multiple divs overlapping, only one of them gets triggered. Is there a way to trigger events on all overlapped same level divs? Here is an example code snippet: ...

What is the correct way to update the state in an array of objects using useState?

I'm struggling to figure out how to use the React useState hook properly. In my todolist, I have checkboxes and I want to update the 'done' property to 'true' for the item that has the same id as the checkbox being clicked. Even th ...

Is there a way to align both the horizontal and rotated lines to intersect at a common point in HTML and CSS?

As a beginner, I'm looking to create a structure resembling a thigh, leg, and ankle using thick lines. My aim is to rotate them with animation, ensuring that the joints between the lines mimic those of a knee joint and hip joint. Below is the code sn ...

Learn how to create a "generated" texture coordinate in three.js similar to how it is done in Blender Cycles

How can I properly display a texture on a cylinder object using THREE.js without distortion? Currently, the texture appears stretched along the edges of the cylinder as shown here: https://i.sstatic.net/O2YFr.png This issue is based on the texture provide ...

Can general principles be applied to determine which script is the most efficient and will load the quickest?

Is there a way to determine which script is optimal and will load faster when there are multiple ways to write scripts that achieve the same outcome? ...

The Express application appears to be unresponsive, but the data has been successfully saved to the MongoDB database. An error with the

Currently, I am delving deeper into the MERN stack and working on a straightforward CRUD application utilizing it. One of the recent additions to the app includes validators implemented through express-validator for handling requests. However, an issue ari ...