开发者

regex parser and custom escape chacter

I have a string that I'd like to pick out sub-strings from that start and end with a plus sign.

example:

text +na开发者_如何学JAVAme+ filler with /+ sign +b+ bold text +/b+

I'd like to pick out the +name+ +b+and the+/b+, but my current regex would treat + sign + as a possible value"

this is the regex I am using \+[\-@\w\s\d\/\!]*\+

I've tried adding a [^/] in front, but that adds whatever character there was before the + and cannot deal with +n++b+

I'm trying to figure out the lookaround and lookbehind, just not sure how to apply it.


The negative lookbehind looks like this (?<!/). This only matches if the previous character is not a /.

Example:

(?<!/)\+[^+]*\+

Note:

  • You may have to escape the / if you are using that character as the delimiter for your regular expression.
  • Not all regular expression engines suport lookbehinds.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜