码迷,mamicode.com
首页 > 其他好文 > 详细

字符串中的几种常用的方法

时间:2014-12-02 18:43:49      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   sp   on   div   

using UnityEngine;
using System.Collections;

public class UserRegister : MonoBehaviour {

    void Start () {
        string s = "   http://www.taikr.com   ";
        print(s);
        string s1=s.Trim();//Trim()去掉两端的空格。
        print(s1);

        string s2 = "http://www.takir.com";
        int index=s2.IndexOf("takir");//Index0f(string str)返回str的位置,匹配第一个。
        print(index);//结果11,从零开始数,不存在则为-1


        string s3 = "Siki is a good man,he singing good!";
        int index1=s3.LastIndexOf("good");//LastIndexOf(string str);返回最后一个匹配
        print(index1);//30,不存在则为-1
    }
}

 

字符串中的几种常用的方法

标签:style   blog   http   io   ar   color   sp   on   div   

原文地址:http://www.cnblogs.com/heisaijuzhen/p/4138049.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!