Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is a single \n getting spanned? #28

Open
WilDoane opened this issue Feb 17, 2015 · 1 comment
Open

Why is a single \n getting spanned? #28

WilDoane opened this issue Feb 17, 2015 · 1 comment

Comments

@WilDoane
Copy link

No description provided.

@briandk
Copy link
Owner

briandk commented Feb 17, 2015

@WilDoane writes:

I think [^:]* is matching \n.

In the example below, the regexp will match the first line and all characters on the second line prior to the colon.

[^:]*

#### hhhh
a: jwjwjw

That is, the above example matches #### hhhh\na

Compare the above regexp to an expression that matches anything not a colon that is followed by a newline:

[^:\n]*

#### hhhh
a: jwjwjw

The modified expression stops matching at the newline, so one could capture just the #### hhhh part.

Subsequently, the JavaScript might be able to be rewritten as:

var speechWithSpeaker = /^\s*([^\n:]*):\s+(.*)/;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants