How do I tokenize input using Java's Scanner class and regular expressions?

前端 未结 4 1556
北海茫月
北海茫月 2021-01-01 03:46

Just for my own purposes, I\'m trying to build a tokenizer in Java where I can define a regular grammar and have it tokenize input based on that. The StringTokenizer class i

4条回答
  •  借酒劲吻你
    2021-01-01 04:06

    If this is for a simple project (for learning how things work), then go with what Balint Pato said.

    If this is for a larger project, consider using a scanner generator like JFlex instead. Somewhat more complicated, but faster and more powerful.

提交回复
热议问题