【发布时间】:2009-06-01 18:41:59
【问题描述】:
我正在尝试编写一个解析wikiCreole 文本的CF 组件。不过,我无法使用我的一些正则表达式获得正确的匹配。我觉得如果我能把头绕到第一个周围,其余的就会点击。这是一个例子:
以下是输入示例:
You can make things **bold** or //italic// or **//both//** or //**both**//.
Character formatting extends across line breaks: **bold,
this is still bold. This line deliberately does not end in star-star.
Not bold. Character formatting does not cross paragraph boundaries.
我的第一次尝试是:
<cfset out = REreplace(out, "\*\*(.*?)\*\*", "<strong>\1</strong>", "all") />
然后我意识到它不会匹配没有给出**的地方,它应该在有两个回车的地方结束。
所以我尝试了这个:
<cfset out = REreplace(out, "\*\*(.*?)[(\*\*)|(\r\n\r\n)]", "<strong>\1</strong>", "all") />
它很接近,但由于某种原因它给了你这个:
You can make things <strong>bold</strong>* or //italic// or <strong>//both//</strong>* or //<strong>both</strong>*//.
Character formatting extends across line breaks: <strong>bold,</strong>
this is still bold. This line deliberately does not end in star-star.
Not bold. Character formatting does not cross paragraph boundaries.
有什么想法吗?
PS:如果有人对更好的标签或这篇文章的更好标题有任何建议,我会全力以赴。
【问题讨论】:
标签: regex parsing coldfusion wiki