Detect end of line or end of string with Javascript regex -


i'm trying find javascript regex detect keyword (any character) followed either new line or end of string. attempt:

.+(?:\n|$) 

i'm not sure $ can used in or condition. thoughts?

update

what trying detect regex keyword follow either (1) keyword, or (2) nothing (therefore new line or end of string)

for example: string "aaa" right before new line match; string "bbb" @ end of string match well.

here go: https://regex101.com/r/tp5ev8/2

/[a-z]+$/gm 

g returns multiple matches , m multi line
$ matches new line

this matches last keyword of line. here 1 matches 1 or several words separated space , ending in newline: https://regex101.com/r/zb9bs0/1

(?:(?: |^)([a-z]+))+$ 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -