swift 使用正则表达式拆分 css 线性渐变

swift split css linear-gradient using regex

我有这样的 css 渐变:

linear-gradient(193deg, rgba(2,0,36,1) 0%, rgba(78,74,64,1) 35%, rgba(0,212,255,1) 100%);

我想使用正则表达式将其转换为 Swift 渐变信息,例如:[颜色]、天使、[位置]。 我试过这个正则表达式

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

但还是不行 https://regex101.com/r/O581sO/1/

我的预期输出 [ 193, [2,0,36,1], 0, [78,74,64,1], 35, [0,212,255,1], 100 ]

你能试试这个表达式吗?这应该可以让你在群组中得到你想要的东西

linear-gradient\((\d+)deg|,\s+(?:(?:rgba\((.*?)\)).+?(\d+)%)+