Intercept string Substitution Chengshing number

Source: Internet
Author: User

1  Public classTestDemo8 {2 3     final static String STARS = "*******************************"; 4 5      Public Static voidMain (string[] args) {6 7String s = "(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.217) (PORT = 1521))";8           intBeginindex = S.indexof ("H");9           intEndIndex = S.lastindexof ("7");TenString news = S.substring (Beginindex, endindex+1); One            ASystem.out.println ("s ..." +s); -System.out.println ("Beginindex ..." +beginindex); -System.out.println ("EndIndex ..." +endIndex); theSYSTEM.OUT.PRINTLN ("News ..." +news); -           -        System.out.println ("Getemail ..." +getemail ("[email protected]");      -     } +      A      Public Staticstring Getemail (string email) { at         if(Email = =NULL) -;//Error -string[] Emailparts = Email.split ("@"); -         if(Emailparts.length! = 2) -;//Format Error -         intLen = emailparts[0].length (); inString char1 = emailparts[0].substring (0, 1); -String char2 = emailparts[0].substring (len-1, Len); to      //String char3 = stars.substring (0, len-2); //intercept Intermediate string bits +String CHAR3 = "* * *"; -          theSystem.out.println ("1 ..." + emailparts[0]);//Liudehua *System.out.println ("2 ..." + emailparts[1]);//126.com $System.out.println ("Char1 ..." + char1);//LPanax NotoginsengSystem.out.println ("Char2 ..." + char2);//a -          the         returnchar1+char3+char2+ "@" +emailparts[1]; +     } A  the}


The output results are as follows:

S ... (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.217) (PORT = 1521))
Beginindex ... 28
EndIndex ... 47
News ... HOST = 192.168.1.217
1...liudehua
2...126.com
Char1...l
Char2...a
Getemail...l***[email protected]

The experience of intercepting strings commonly used in Java

Http://jingyan.baidu.com/article/a17d5285224c918098c8f215.html

Intercept string Substitution Chengshing number

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.