我正试图解析ics日历文件的描述,如下所示

对于PCRE,这很好,但是当我尝试将它转换为iOS/ICU使用时,我得到了以下结果:
let descriptionRegex = "(?m)DESCRIPTION:(.*(?:\\n :?.*)*)"返回:"What is the purpose of the stand up meeting? \nIt is a 15 "
当将此转换为ICU表达式时,我没有考虑哪些更改?
原文:
DESCRIPTION:The purpose of a retrospective meeting is to reflect on th
e previous sprint together with the development team to learn from our
mistakes. \nIs the team performing well or what can we do to improve
our way of working\, our efficiency\, and so on. \nAny topic can be di
scussed\, we strive for open communication in this meeting to continuo
usly improve as a team. \n\nWe try to list: \n - Engine
: what is working well and what do we continue doing? \n - Anchor
: what didn't we do well or what went wrong\, so what do we stop doing
or can be improved? \n - Try
: which actions do we take\, which things do we try in the next sprint
to improve? \n\nAfter the retrospective\, I want to have a look at th
e sprint plan\, to decide which user stories we work on next with the
team.发布于 2016-02-09 14:01:01
结果可能是文件中有不同的换行符序列(\r或\r\n,或者只是\n,甚至是混合的)。因此,您可以尝试用\R替换正则表达式中的\R。
此外,如果您希望在某些分隔符之间匹配一些未知数目的字符,则可以使用可以展开的(?s)DEL1(.*?)(?=DEL2)正则表达式,以便根据DEL2分隔符获得更好的性能。
这里有一个用于您的场景:
(?m)^DESCRIPTION:([^\n]*(?:\n++(?![A-Z]+:)[^\n]*)*)请参阅regex演示
[^\n]*(?:\n++(?![A-Z]+:)[^\n]*)*部件是(?ms).*?(?=^[A-Z]+:)的展开版本。展开正则表达式的优点是,不依赖于DOTALL修饰符。它可以跨越多条线进行匹配。另外,与惰性点匹配模式相比,性能通常要好得多。
https://stackoverflow.com/questions/35293487
复制相似问题