admin管理员组文章数量:1391987
I'm trying to match parts of a larger block of content and want to only match things at the start of the string or that are preceded by a space and I only want to match things that end at the end of string or are followed by a space. Unfortunately, my regex-fu is a bit too weak to figure this out on my own. Help me Stack Overflow, you are my only hope.
Basically these should all match "the-thing-to-match";
the-thing-to-match blah
blah the-thing-to-match
blah the-thing-to-match blah
I'm trying to match parts of a larger block of content and want to only match things at the start of the string or that are preceded by a space and I only want to match things that end at the end of string or are followed by a space. Unfortunately, my regex-fu is a bit too weak to figure this out on my own. Help me Stack Overflow, you are my only hope.
Basically these should all match "the-thing-to-match";
the-thing-to-match blah
blah the-thing-to-match
blah the-thing-to-match blah
Share
Improve this question
asked Aug 28, 2010 at 1:35
Stephen BelangerStephen Belanger
6,36112 gold badges47 silver badges49 bronze badges
1
- Check out regular-expressions.info/wordboundaries.html too; it may (or may not) be useful. – polygenelubricants Commented Aug 28, 2010 at 12:35
1 Answer
Reset to default 7/(?:^| )the-thing-to-match(?: |$)/
EDIT: Remove quantifiers.
本文标签: javascriptregex space or start of inputspace or end of inputStack Overflow
版权声明:本文标题:javascript - regex space or start of input, space or end of input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744611218a2615667.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论