Normal Java pattern recognition library - for example, regular expressions for List <Object>

Is there a library that allows me to write regexp-like queries for lists of objects, just like java.util.regexp matches strings that are conceptually similar to character lists?

I want to be able to use patterns with greedy / conservative quantifiers, identify groups in matches, etc. Obviously, I would have to provide code to map the request token to the object in the list.

I'm not just trying to save time by not writing my own query parser. I know that implementing regular expressions (against strings) is a well-researched area, and Sun java.util.regex has undoubtedly got rid of this a long time ago. Everything that I write will not be nearly as effective, and I may have to process fairly long lists (but rather simple queries).

Thanks!

+3
source share
3 answers

The idea, if the objects stored in the list are limited, is to create a Map between the object in the list and the unique Unicode character for this object. Therefore, given your list, you will create a string of characters that uniquely represent the list.

regex , . .

+1

- Quaere. :

Quaere - , , SQL Java. Quaere , , .

+2

, , , , .

, - , , - , "X" , "Y" ( , apache commons, , beanutils commons). ? , , , - " X Y *". .

, . , , - . ?

0

Source: https://habr.com/ru/post/1714681/


All Articles