我有一些VBA宏,我需要翻译所有输出消息,但这些消息包含在双引号之间,如下所示:
If Not IsNumeric(Sheet28.Range("I9")) Then
Call MsgBox("Error! Voucher expiry years must be a number", vbDefaultButton1 Or vbExclamation, "Error!")
Application.Undo
End If
我想要这个:
"I9"
"Error! Voucher expiry years must be a number"
"Error!"
是否可以使用grep,sed,awk,regex或其他东西来做?
“I9”不是消息,但我将负责删除不是消息的文本,删除重复项等。
提前致谢!
答案 0 :(得分:0)
您可能想要一种模式,例如:
SELECT b.provider,a.title,b.ttl,sum(a.revenue) AS rev
FROM tab AS a
JOIN (
SELECT provider,sum(revenue) AS ttl FROM tab GROUP BY 1
) AS b ON a.provider = b.provider
GROUP BY 1,2,3
ORDER BY 3 DESC,2
使用"[^"]+" # matches I9 also
"[^)I"]+" # won't match messages starting with "I"
"[^"]+?" # lazy match in case you aren't using grep, egrep, etc.
"[^"][^0-9(]+" # won't match messages with the second character as digit.
或grep
:
egrep
匹配grep -Eo '"[^"]+"'
egrep -o '"[^"]+"'
,"I9"
,"Error!"
"
"Error! Voucher expiry years must be a number
匹配grep -Eo '"[^"][^0-9(]+"'
,"Error!"
,"Error! Voucher expiry years must be a number"
"I match also"
字面匹配字符"
(区分大小写)"
[^I)"]
量词 - 在一次和无限次之间匹配,尽可能少,根据需要扩展(懒惰)示例强>: