Since the professional is machine learning, that work must also continue to deal with data, then the problem comes, many times the recommendation algorithm and data mining algorithms are readily available, the platform was initially built, focus on data filtering and extraction, how to extract data efficiently?
Use the usual algorithm in the game of string processing method, OMG, maintenance It is a faint pain of sadness.
So, the point is, the regular expression, neat.
The template is as follows:
Step1,set reg stringstring regstr = "^helloworld"
Step2,set Patternpattern Regpattern = Pattern.compile (REGSTR);
Step3,set Matchermatcher regmatcher = Regpattern.matcher (Srctext);
Step4,display What is found from this patternif (Regmatcher.find ()) { System.out.print (Regmatcher.group ());}
Of course, first you have to write a regular expression, remember, can be grouped in groups, feature-related data extraction will be smooth.
Template is very simple, regular extraction of the regular expression is the focus.
So, what to do with multiple matches, remember, regular extraction is a tree structure, with a for loop, you lose.
Solution: State machine, even, you can do this with a callback function (callable interface)
This belongs to the something, the code word tired, today is mainly unwinding.
"Benefits" Java Regular expression template