简体   繁体   English

正则表达式以匹配线性梯度及其来自字符串的内容

[英]Regular expression to match linear-gradient and its content from a string

I get computed background style of an element and the result is like this: 我得到一个元素的计算背景样式,结果是这样的:

rgba(0, 0, 0, 0) linear-gradient(45deg, rgba(126, 47, 182, 0) 0%, rgba(126, 47, 182, 0) 25%, rgba(249, 71, 157, 0) 80%, rgba(249, 71, 157, 0) 100%) repeat scroll 0% 0% / auto padding-box border-box

What regular expression can I use to match only linear-gradient(45deg, rgba(126, 47, 182, 0) 0%, rgba(126, 47, 182, 0) 25%, rgba(249, 71, 157, 0) 80%, rgba(249, 71, 157, 0) 100%) 我可以使用什么正则表达式来仅匹配线性梯度(45deg,rgba(126,47,182,0)0%,rgba(126,47,182,0)25%,rgba(249,71,157,0 )80%,rgba(249,71,157,0)100%)

Try the : 试试

linear-gradient\([^(]*(\([^)]*\)[^(]*)*[^)]*\)

视觉的

See demo in https://regex101.com/ 请参阅https://regex101.com/ 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM