C # string manipulation takes text to the left to take text to the right of the middle of the text to the middle of the list to specify the text in reverse

Source: Internet
Author: User
Tags reverse text

        /// <summary>        ///take text left content/// </summary>        /// <param name= "str" >text</param>        /// <param name= "S" >identifiers</param>        /// <returns>left content</returns>         Public Static stringGetLeft (stringStrstrings) {stringtemp = str. Substring (0, str.            IndexOf (s)); returntemp; }        /// <summary>        ///take text to the right content/// </summary>        /// <param name= "str" >text</param>        /// <param name= "S" >identifiers</param>        /// <returns>Right Content</returns>         Public Static stringGetRight (stringStrstrings) {stringtemp = str. Substring (str. IndexOf (s), str. Length-str.substring (0, str. IndexOf (s)).            Length); returntemp; }        /// <summary>        ///take text intermediate content/// </summary>        /// <param name= "str" >Original Text</param>        /// <param name= "Leftstr" >left Text</param>        /// <param name= "Rightstr" >Right Text</param>        /// <returns>return Intermediate text content</returns>         Public Static stringBetween (stringStrstringLEFTSTR,stringrightstr) {            inti = str. IndexOf (LEFTSTR) +Leftstr.            Length; stringtemp = str. Substring (i, str.) IndexOf (RIGHTSTR, i)-i); returntemp; }        /// <summary>        ///take text middle to list collection/// </summary>        /// <param name= "str" >text string</param>        /// <param name= "Leftstr" >left Text</param>        /// <param name= "Rightstr" >Right Text</param>        /// <returns>List Collection</returns>         Publiclist<string> Betweenarr (stringStrstringLEFTSTR,stringrightstr) {List<string> list =Newlist<string>(); intLeftindex = str. IndexOf (LEFTSTR);//left text start position            intLeftlength = Leftstr. Length;//left text length            intRightindex =0; stringtemp ="";  while(Leftindex! =-1) {Rightindex= str. IndexOf (RIGHTSTR, Leftindex +leftlength); if(Rightindex = =-1)                {                     Break; } temp= str. Substring (Leftindex + leftlength, Rightindex-leftindex-leftlength); List.                ADD (temp); Leftindex= str. IndexOf (LEFTSTR, Rightindex +1); }            returnlist; }        /// <summary>        ///specify text in reverse/// </summary>        /// <param name= "str" >text</param>        /// <returns>Reverse Text</returns>         Public Static stringStrReverse (stringstr) {            Char[] chars =Str.            ToCharArray (); StringBuilder SB=NewStringBuilder ();  for(inti =0; I < chars. Length; i++) {sb. Append (Chars[chars. Length-1-i]); }            returnsb.        ToString (); }

C # string manipulation takes text to the left to take text to the right of the middle of the text to the middle of the list to specify the text in reverse

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.