Javascript/REGEX:删除一个特定的文本(单词),该单词以String中的特定字母开头,单词用空格分隔

Eri*_*est 0 javascript regex string text replace

我知道这可以通过Regex快速完成:

我得到的字符串如下:

"Alpha OmegaS Sheol Gehena GSSaga Serekali"

我想删除以s开头的单词.

所以我应该:

"Alpha OmegaS Gehena GSSaga"

我试过了什么?

就像是: str.replace(/^\\S/,"") //This NO GOOD.

事情是我非常了解REGEX,但不知何故REGEX不理解我.

任何帮助表示赞赏.

Tot*_*oto 6

怎么样:

str.replace(/\bs\S+/ig,"")
Run Code Online (Sandbox Code Playgroud)

说明:

NODE                     EXPLANATION
----------------------------------------------------------------------
  \b                       the boundary between a word char (\w) and
                           something that is not a word char
----------------------------------------------------------------------
  s                        's'
----------------------------------------------------------------------
  \S+                      non-whitespace (all but \n, \r, \t, \f,
                           and " ") (1 or more times (matching the
                           most amount possible))
----------------------------------------------------------------------

i is for case-insensitive
g is for global
Run Code Online (Sandbox Code Playgroud)