Regexp to find strings enclosed by ** (double-star)
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 开发者_如何学Pythonsit and semper and I really don't know how to manage it.
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..
\s*{2}([^\*]+)\s*{2}
精彩评论