字串常用操作

2021-09-29 06:14:42 字數 518 閱讀 7942

/*

* 查詢子串

*/string str1="dwqae12232aebdalf";

//查詢指定字串第一次出現的位置,如果沒有返回-1

int first2=str1.indexof("12");

//查詢指定字串第一次出現的位置,從索引處開始(包括索引處

int first4=str1.indexof("12232",0);

//查詢指定字元最後一次出現的位置

str1..lastindexof('a')

/** 擷取字串

*///從索引處到末尾

string substr1=str1.substring(5);

//指定區間(包括結束索引處)

string substr2=str1.substring(5, 10);

/** 分割字串

*///以a為分割字元

string splitstr=str1.split("a");

字串常用操作。。。

include include include char itoa int value result char malloc sizeof char i 1 for j 0 jint i 65 char p itoa i printf s n p free p p null include incl...

字串常用操作

coding utf 8 import string1 判斷str unicode字串物件 def isastring anobj return isinstance anobj,basestring basesting是str,unicode的父類 defisaint anobj return i...

字串常用操作

一 變換大小寫 string.tolowercase string.touppercase var big qwertyu big.tolowercase qwertyu var yh qwertyui yh.touppercase qwertyui 二 獲取字串長度 var yy 好好學習前端做個...