Android simple Application (iv)--string processing

Source: Internet
Author: User

In Java, there are many ways to manipulate strings, and you can do so by importing the appropriate string-handling Lib package. But today is the two ways to deal with strings that you see on Android.

First, regular expression

In fact, the regular expression is not as difficult as everyone think (although I have to check the data to write), it is like a word game, the rules are placed there, we just remember the rules can let us free play.
As for what is regular expression, I do not popularize the basic knowledge here, this online tutorial really a lot, you can see here http://blog.csdn.net/luosijin123/article/details/4792181

The General Java notation

        Pattern pattern; // compiler        Matcher Matcher; // Matching device        Pattern = Pattern.compile (". *cpacm.*"); // The regular expression to be compiled is placed in the compiler, which means matching all strings        that contain the CPACM field Matcher = Pattern.matcher (p); // to see if a string matches        by a matching device if (Matcher.matches ()) {// match            return true ;        }         return false;

Very simple

Second, textutils

This class I found in Android, I do not know whether Java itself to bring this class. Its function is simple, which is to handle strings for you, including:

    1. Find the position of a character in a string
    2. The
    3. Create a child string
    4. String segmentation
    5. Determines whether the empty
    6. String inversion
    7. Rewrite one of these little pieces

And so on, these are commonly used string operations, the details can look at the source code or API http://www.apihome.cn/api/android/TextUtils.html

The source code is in Android.text.TextUtils.

Android simple Application (iv)--string processing

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.