Click here to Skip to main content
14,325,129 members
Rate this:
Please Sign up or sign in to vote.
I want to extract the content of the CSS using the regular expression.

I have tried various things, but the problem starts to appear when I am trying to extract the CSS from the media queries.

But what I have tried doesnt select media query in whole single block.

What I have tried:

(?ims)([a-z0-9\[\]\s\.\:#_\(-@)(~)(%),]+)\{([^\}]*)\}(\s*\})?


Here is a link where I have tried this
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[^]
@media screen and (min-width:1200px) {
	.testMe {
		position: relative;
		margin-bottom: 0;
		background-color: #fff;
		z-index: 30
	}
	.testMeAgain:after {
		content: "";
		display: block;
		height: 40px;
		width: 100%;
		position: absolute;
		bottom: 0;
		border-style: solid;
		border-color: #d5d6d2;
		border: 0;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
		background-color: #0099b2
	}
	.test-sticky {
		position: fixed;
		width: 100%;
		top: 0;
		left: 0;
		right: 0
	}
	.test-sticky .responsiveSubMenu {
		display: none
	}
}

.testCheck .testCheck::-webkit-scrollbar {
	width: 8px
}
Posted
Updated 3-Sep-19 9:31am
v2
Comments
MadMyche 3-Sep-19 17:56pm
   
OK, so you want to extract the CSS; but what program type will this be- PHP, .NET, ???
Member 11491784 4-Sep-19 5:23am
   
PHP

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100