我需要一个正则表达式或类似的。我有一系列字符串,格式为:
S 8010-Y30R
7020-R
S 7020-R
3852-R10B
By the last letter in the order: Y R B G
Then by the last two digits
Then by the second last letter (if any) in the order: Y R B G
Then by the two digits
Then by the first two digits
所以这个例子是:S 8010-Y30R would be ordered by: R 30 Y 10 80
第二个例子:7020-R is a short version of: S 7020-R _ _ _
我可以在excel中订购这些…或者使用JavaScript对两个数组进行排序(一个包含上面的颜色代码,另一个包含相同的RGB版本)。
试试这个:
Search string
^[A-Z]? ?(dd)(dd)-([A-Z]?)(dd)?([A-Z])?$
Replace string
$5$4$3$2$1
假设总是出现的项是连字符前面的四位数字,以及连字符本身。其他的都是可选的,你不会想要保留第一个字母。每个字符串单独出现在一行中