【发布时间】:2016-09-08 15:48:36
【问题描述】:
我想从
重新格式化我的 Swift 文档/**
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
*/
到
/// Lorem Ipsum is simply dummy text of the printing and typesetting industry.
/// Lorem Ipsum has been the industry's standard dummy text ever since the
/// 1500s, when an unknown printer took a galley of type and scrambled it to
/// make a type specimen book. It has survived not only five centuries, but
/// also the leap into electronic typesetting, remaining essentially
/// unchanged. It was popularised in the 1960s with the release of Letraset
/// sheets containing Lorem Ipsum passages, and more recently with desktop
/// publishing software like Aldus PageMaker including versions of Lorem Ipsum.
正则表达式查找和替换 edit: ,使用 Xcode 的查找/替换正则表达式引擎, 将是首选,因为上帝只知道我的 200 多个不同类的库中有多少文档注释。查找这些块的表达式很简单,但我不知道如何制作我的替换表达式,以便我能够为每一行添加一个前缀。
当前搜索表达式: (?s:/\*\*(.*?)\*/) - 匹配 /** */ 之间的所有文本
当前替换表达式:/// $1
显然,上面的表达式并没有完全达到我想要的效果。提前感谢任何帮助!谢谢。
【问题讨论】:
-
关键问题:您使用什么工具进行替换?
-
Xcode 的查找和替换正则表达式引擎。 @TimBiegeleisen
-
我不确定您是否可以通过一次查找和替换来完成...
-
@ThomasAyoub 不幸的是,我想这么多;有什么建议如何使用不止一个步骤来完成吗?
-
不容易,但我明白了!仍然有两个步骤(我坚定地认为这是不可能的),并且还需要 PCRE 正则表达式,我不确定 Xcode 是否适合。第一个(疯狂的)表达式传入的解释。
标签: regex swift string replace