开发者

REGEXP and expressions beginning at start of string or with a separator

I'd like a REGEXP that only picks up a substring that either starts at the beginning开发者_JS百科 of the string or is preceded by a space or separating character. How does this work?

For example,

[ _^]Smith

seems to be almost it!


(^|[ _])Smith

^ (start) or one of [ _] followed by Smith

(| is the or operator)


Something like this:

^[ _]?Smith

^- beginning of line
[ _]? - space or underscore 0 or one time

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜