Java extracts numbers from a string

Source: Internet
Author: User

1, do a bit of operation will generally use to extract digital manipulation:

A, the list of pages, when the newly added data is not placed in the first or last, you need to page and loop to find the corresponding data

B, when the newly added data is placed in the first or the last one, you do not need to page, just go directly to the page and then directly find the first or the last piece of data.

2. Example:

Interface:

Javs Code:

/** * Java extracts a number from a string * str: Passed over the string */public static list<string> Getnum (String str) {Str.trim ();
String Number=lnum.substring (3, 4);//directly gets the number in the passed string (for a string containing only a number) list<string> ss=new ArrayList <String> (); For (String Sss:str.replaceAll ("[^0-9]", ","). Split (",")) {//First replace the string with an "," and then use "," to split the string into an array if (sss.length () >0) Ss.add (SSS); return SS;}

Note: The above str parameter refers to a string (usually the text passed over the page, such as: page, total 3 pages)

Java extracts numbers from a string

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.