为什么这个正则表达式不起作用

本文关键字:不起作用 正则表达式 为什么 | 更新日期: 2023-09-27 18:34:22

我不知道

为什么下面的表达式不起作用。我期待着在 C# 和 JavaScript 代码中同时工作的单一正则表达式模式。

模式

^Format=UniqueIdentifier:CanvasHeight:CanvasWidth[]CommaSeparated[[]Lx:Ly:Mx:My[]]#Values=[0-9a-zA-Z

]+:[0-9]+:[0-9]+[][-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+(,[-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+(*$

价值

格式=唯一标识符:画布高度:画布宽度*逗号分隔[Lx:Ly:Mx:My]#Values=1393:80:300*29:18:29:17,29:19:29:18,28:23:29:19,26:27:28:23,26:32:26:27,25:35:26:32,24:39:25:35,23:44:24:39,22:48:23:44,22:50:22:48,22:53:22:50,21:55:22:53,20:57:21:55,20:58:20:57,20:59:20:58,20:60:20:59,20:61:20:60,18:62:20:61,18:64:18:62,18:65:18:64,18:66:18:65,18:31:18:30,19:27:18:31,22:26:19:27,25:23:22:26,31:21:25:23,40:18:31:21,47:17:40:18,55:15:47:17,62:15:55:15,67:13:62:15,70:13:67:13,71:13:70:13,72:13:71:13,73:13:72:13,74:13:73:13,75:13:74:13,75:15:75:13,73:18:75:15,72:19:73:18,71:20:72:19,69:22:71:20,68:23:69:22,64:27:68:23,63:28:64:27,61:29:63:28,59:31:61:29,57:32:59:31,55:33:57:32,54:33:55:33,52:34:54:33,52:35:52:34,51:35:52:35,50:36:51:35,47:37:50:36,46:38:47:37,45:38:46:38,45:40:45:38,45:41:45:40,44:43:45:41,43:44:44:43,42:44:43:44,104:37:104:36,102:36:104:37,97:38:102:36,88:40:97:38,85:42:88:40,80:44:85:42,76:45:80:44,71:48:76:45,70:49:71:48,66:50:70:49,66:51:66:50,65:52:66:51,65:54:65:52,65:55:65:54,65:56:65:55,65:57:65:56,65:58:65:57,66:58:65:58,68:58:66:58,69:58:68:58,72:58:69:58,75:58:72:58,77:57:75:58,80:56:77:57,82:54:80:56,84:52:82:54,85:51:84:52,85:50:85:51,85:49:85:50,86:50:85:49,86:53:86:50,86:54:86:53,88:56:86:54,90:57:88:56,91:57:90:57,91:56:91:57,92:54:91:56,92:51:92:54,92:50:92:51,92:49:92:50,93:49:92:49,93:47:93:49,96:46:93:47,105:43:96:46,109:43:105:43,116:42:109:43,118:40:116:42,120:39:118:40,121:39:120:39,122:39:121:39,122:40:122:39,122:43:122:40,122:45:122:43,122:47:122:45,122:49:122:47,122:50:122:49,122:51:122:50,122:52:122:51,123:53:122:52,124:53:123:53,125:53:124:53,128:52:125:53,128:51:128:52,131:45:128:51,133:41:131:45,134:35:133:41,134:31:134:35,136:29:134:31,136:27:136:29,137:25:136:27,137:21:137:25,137:20:137:21,137:19:137:20,137:20:137:19,137:26:137:20,137:28:137:26,137:32:137:28,138:37:137:32,139:40:138:37,139:43:139:40,140:45:139:43,141:47:140:45,142:47:141:47,142:48:142:47,142:49:142:48,143:49:142:49,144:48:143:49,145:47:144:48,146:43:145:47,147:42:146:43,148:40:147:42,149:38:148:40,149:35:149:38,151:34:149:35,152:32:151:34,154:29:152:32,154:28:154:29,154:27:154:28,154:26:154:27,154:25:154:26,153:25:154:25,152:28:153:25,152:32:152:28,152:36:152:32,151:38:152:36,151:40:151:38,151:41:151:40,151:43:151:41,150:44:151:43,150:45:150:44,150:46:150:45,150:47:150:46,150:48:150:47,150:49:150:48,150:50:150:49,150:51:150:50,150:52:150:51,150:53:150:52,152:53:150:53,155:52:152:53,159:49:155:52,163:47:159:49,165:47:163:47,169:45:165:47,171:45:169:45,173:45:171:45,174:45:173:45,175:45:174:45,177:46:175:45,178:47:177:46,180:48:178:47,182:48:180:48,185:49:182:48,187:49:185:49,188:49:187:49,190:48:188:49,191:48:190:48,192:47:191:48,193:46:192:47,194:45:193:46,194:44:194:45,196:43:194:44,196:42:196:43,197:40:196:42,198:39:197:40,199:38:198:39,200:38:199:38,201:37:200:38,201:36:201:37,65:69:65:68,67:68:65:69,70:68:67:68,76:68:70:68,86:68:76:68,98:68:86:68,110:68:98:68,133:68:110:68,150:68:133:68,166:68:150:68,184:68:166:68,195:67:184:68,206:67:195:67,210:67:206:67,213:66:210:67,238:51:238:50,303:39:303:38

为什么这个正则表达式不起作用

该死的,我在 Regex.IsMatch(( 中放错了模式和值。都很好。

这是在 C# 和 JavaScript 中都有效的模式。

^Format=UniqueIdentifier:CanvasHeight:CanvasWidth'*CommaSeparated'[Lx:Ly:Mx:My']#Values=[0-9a-zA-Z]+:[0-9]+:[0-9]+'*[-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+(,[-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+:[-]{0,1}[0-9]+)*$