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

Regex space counting is very restricting #1

Open
olsonpm opened this issue Nov 25, 2014 · 0 comments
Open

Regex space counting is very restricting #1

olsonpm opened this issue Nov 25, 2014 · 0 comments

Comments

@olsonpm
Copy link

olsonpm commented Nov 25, 2014

I was wondering why you opted to use the regex to count spaces? It's restricting in the sense that it neither accounts for double spaces after a period (habit of mine) nor does it account for line breaks in the files containing html.

When I figured out the problem, I replaced the regex logic with:

var beforeLastSpace = str.substring(0, str.lastIndexOf(' '));
var afterLastSpace = str.substring(str.lastIndexOf(' ') + 1, str.length);
var res = beforeLastSpace + ' ' + afterLastSpace;

and it works fine for my case. I would send a pull request - but I figured I'd ask about it first because you may have very good reasons.

Thanks much for your plugin

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

1 participant