正则表达式查找由 **(双星)括起来的字符串
我正在尝试找到一种方法来从字符串中生成匹配模式的数组。 我将用一个例子来解释自己。
从像我这样的字符串中,
Lorem ipsum dolor **sit** amet, consectetur adipiscing elit.
Nulla elementum euismod mi. Morbi eu eros eget augue vestibulum semper.
Curabitur sapien purus, **semper** in consequat eu, gravida vitae purus.
我需要应用正则表达式来提取单词 sit 和 semper 我真的不知道如何管理它。
I'm trying to find a way to make an array of matched patterns out of a string.
I'll explain myself with an example.
From a string like
Lorem ipsum dolor **sit** amet, consectetur adipiscing elit.
Nulla elementum euismod mi. Morbi eu eros eget augue vestibulum semper.
Curabitur sapien purus, **semper** in consequat eu, gravida vitae purus.
I need to apply a regexp to extract the words sit and semper
and I really don't know how to manage it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为像
\*{2}(.*?)\*{2}
这样的正则表达式会处理它,并在 Objective-C 中使用正则表达式(假设你在一个Apple 平台)您需要查看 NSRegularExpression iOS 或 Mac 文档。I would think a regex such as
\*{2}(.*?)\*{2}
would take care of it, and using regular expressions in Objective-C (assuming you're on an Apple platform) you'd want to look at the NSRegularExpression iOS or Mac documentation.你可以这样做..
You can do it like this..