"Benefits" Java Regular expression template

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.