Velocity:查找数学字符串并将它们存储在数组中
我有一个文本,我想根据正则表达式模式提取一些字符串:
<div>This is a text</div><div> </div><div>here is another text</div>
How can I store all the events between
and
谢谢。
I have a text and I want to extract some string basing on a regular expression pattern:
<div>This is a text</div><div> </div><div>here is another text</div>
How can I store all the occurences between <div>
and </div>
in an array avoiding the empty/space strings ?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎想要解析 html/xml 文档中的内容。 Velocity 对于获取字符串数组并将它们放入 div 标签中非常有用......而不是相反。
HtmlCleaner 是一个有用的工具,可将 html 格式化为 xml(即包括结束 p 标签和其他内容)。然后您可以使用 xpath 轻松获取 div 标签的内容。
以下是一些未经测试的代码,可以帮助您入门:
It seems that you want to parse content from an html/xml document. Velocity would be useful for taking an array of strings and putting them in div tags... not the other way around.
HtmlCleaner is a useful tool which formats html into xml (i.e. includes closing p tags and things). You can then easily get the content of the div tags using xpath.
Here's some untested code that should get you started: