javascript - How to RegEx in Codemirror to match paragraph first and last words? -
i'm using codemirror build texteditor nice feats such syntax highlighting, using language modes in simple mode, , trying write couple of regex match first , lastly words of paragraph. instance, in:
one first 1 of numbers 2 sec
the first regex (first word in paragraph) should match one
, two
, , sec 1 (last word in paragraph) should match numbers
, second
.
i've been trying different expressions couldn't find right one. closest got, still not right:
/[^\r\n]+[a-za-z]\s/
could point me in right direction? in advance.
tested using notepad++ , rubular.com
find what: ^([a-z]\w+)(\s\w+)?((\r?\n|\r)([a-z]+\s)+)+(\w+)$
replace with: \1\n\6
input
one first 1 of numbers 2 sec 3 3rd 4 4th of numbers
output
one numbers 2 sec 3 3rd 4 numbers
rubular
javascript regex codemirror codemirror-modes
No comments:
Post a Comment