How to use Regex to find a string with only spaces delimiting it? -
i'm trying parse string whitespace delimited.
i using /\b[somestring]\b/
but don't want pick words have any punctuation next it.
so if parsed string:
"trying to,\n test out,\n trying has taken while.\n trying stuff fun,\n stuck" with /\btrying to\b/
i find three, want 2 because don't want include
"trying to," --edit
expected output
trying trying
if understood correctly question, can use regex lookahead this:
trying to(?=\s) the idea search string trying to following space character
edit: if want include having \n, can use:
trying to(?=\s|\\n) btw, if want include literal space , literal \n, don't need use regex lookahead, simple group this:
trying to(?:\s|\\n)
Comments
Post a Comment