更换汤匙和茶匙
我正在使用 BBEdit 或 Visual Code,我对正则表达式不太有经验,但想对“茶匙”的所有实例进行简单的查找和替换(如茶匙或茶匙s )和“汤匙”与“茶匙”和“汤匙”。
Replace:
1 tablespoon sugar
2 teaspoons salt
2 tablespoons butter
3 teaspoons crystal meth
with:
1 tbsp sugar
2 tsp salt
2 tbsp butter
3 tsp crystal meth
替换搜索词应一次性包含所有四种变体。任何帮助将不胜感激。
I'm using BBEdit or Visual Code and I'm not too experienced with regex but would like to do a simple find and replace to all instances of "teaspoon(s)" (as in teaspoon or teaspoons) and "tablespoon(s)" with "tsp" and "tbsp".
replace:
1 tablespoon sugar
2 teaspoons salt
2 tablespoons butter
3 teaspoons crystal meth
with:
1 tbsp sugar
2 tsp salt
2 tbsp butter
3 tsp crystal meth
The replace search term should encompass all four variants in one go. Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从“table”中捕获“b”以在一次替换中完成此操作:
搜索:
\bt(?:a(b)le|ea)spoons?\b
替换:
t$1sp
$1
是捕获内容的占位符(b
,如果有)。You can capture the "b" from "table" to do it in one replacement:
search:
\bt(?:a(b)le|ea)spoons?\b
replace:
t$1sp
$1
is a placeholder for the captured content (theb
if any).