开发者

reg ex group and sub group

Is it possible to use regex to capture a whole phrase as well as each word in the phrase concatenated?

So for :

smith jones

To return:

smith,jones,smithjones

furtherm开发者_JAVA技巧ore due to other constraints (solr PatternTokenizer) i can only use one grouping.


It doesn't look like you'll be able to do this without some extra work. With PatternTokenizerFactory, you are limited to the 'matching' part of regex so you can't do replacements.

Why not create your own tokenizer that uses the token stream created by PatternTokenizer and then builds a concatenated string which it returns at the end?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜