I want to write a regex, which would help to match sequence of symbol } and append string before it. Here's the example text that I want to substitute:

@media (max-width: 600px){#oaw {color: #ccc} #oaw .oa-form form button{width:100%}}

Should become:

@media (max-width: 600px){#oaw {color: #ccc !important} .oa-form form button{width:100% !important}}

I want to match every occurrence of }+ and replace it with !important}+ so that the following replacements would be done:

} -> !important}
}} -> !important}}
and so on..

Is there any way that I could tell regex to match }+ and append !important before it (replace it with custom string and append matched string)?

有帮助吗?

解决方案

Just try with matching:

(} *}?)

and replacing with

 !important $1
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top