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

Does not work with comma #2

Open
giorgio79 opened this issue Nov 13, 2018 · 2 comments
Open

Does not work with comma #2

giorgio79 opened this issue Nov 13, 2018 · 2 comments

Comments

@giorgio79
Copy link

Tried

var diffs = worddiff.diffString(
  "Tom , reads novels but Jack reads comics .",
  "Tom reads novels , but Jack reads comics ."
);

console.log(diffs);

and I am getting

[ { text: 'Tom , reads novels but Jack reads comics .' } ]

Therefore no difference is detected...

@giorgio79
Copy link
Author

And a runkit sample https://runkit.com/embed/lreu16ado691

@eznix86
Copy link

eznix86 commented Sep 10, 2022

That is something to do with

var out = this.diff(o.split(/\s+/), n.split(/\s+/));

it returns only words.

Instead it can use o.split(/\s+|\\W/)

>> "Tom reads novels , but Jack reads comics .".split(/\s+|\\W/)
>> (9) ['Tom', 'reads', 'novels', ',', 'but', 'Jack', 'reads', 'comics', '.']

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