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

support: can't get tokenizer to work #12

Open
jsilvestre opened this issue Dec 24, 2014 · 0 comments
Open

support: can't get tokenizer to work #12

jsilvestre opened this issue Dec 24, 2014 · 0 comments

Comments

@jsilvestre
Copy link

Hi,

I was trying to get the lib to work, but couldn't manage to success, so I hoped you could help me. I have tried the various examples and they all work, but can't get my head around my use case:

Tokenizer = require('tokenizer');
t = new Tokenizer();
t.addRule(/^#[\w\d-_]+$/, 'tag');
t.addRule(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/, 'url');
t.addRule(/^[\s]+$/, 'space');
t.addRule(/^[\w]+$/, 'symbol');
t.on('token', function(token, type) {
    console.log(token, type);
});
t.write("Test with #tag and a http://google.fr/ #url");

Then I get
screenshot-2014-12-24

I think there might be something wrong with my url regex, but I didn't made it up. Is there any chance that I miss something in the way tokenizer work?
Thank you very much, and merry christmas!

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