国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - java實現查找替換功能

java實現查找替換功能

2021-07-27 11:35cat_pp Java教程

這篇文章主要為大家詳細介紹了java實現查找替換功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了java實現查找替換功能的具體代碼,供大家參考,具體內容如下

查找

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if(searchtxt.gettext().equals("")){
          joptionpane.showmessagedialog(null, "查找內容不能為空!");
        }else if(!searchtxt.gettext().equals("")){
          //searchdialog.dispose();
          if(filechoose.focus == 1){
            filechoose.tp1.requestfocus(true);
            str = filechoose.tp1.gettext();
            startposition = str.indexof(searchtxt.gettext());
            endposition = startposition + searchtxt.gettext().length();
            filechoose.tp1.select(startposition, endposition);
            newendposition = endposition;
          }else if(filechoose.focus == 2){
            filechoose.tp2.requestfocus(true);
            str = filechoose.tp2.gettext();
            startposition = str.indexof(searchtxt.gettext());
            endposition = startposition + searchtxt.gettext().length();
            filechoose.tp2.select(startposition, endposition);
            newendposition = endposition;
          }
     }

查找下一處

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
nexttemp = newendposition;
        if(filechoose.focus == 1){
          strall = filechoose.tp1.gettext();
          filechoose.tp1.select(nexttemp, strall.length());//選中所有未查找的字符串
          nextstr = filechoose.tp1.getselectedtext();
          newstartposition = nextstr.indexof(searchtxt.gettext()) + nexttemp;//在未查找的字符串中查找對應字符在tp1中的位置
          newendposition = newstartposition + searchtxt.gettext().length();
          filechoose.tp1.select(newstartposition, newendposition);//找到文本,選擇文本
        }else if(filechoose.focus == 2){
          strall = filechoose.tp2.gettext();
          filechoose.tp2.select(nexttemp, strall.length());//選中所有未查找的字符串
          nextstr = filechoose.tp2.getselectedtext();
          newstartposition = nextstr.indexof(searchtxt.gettext()) + nexttemp;//在未查找的字符串中查找對應字符在tp1中的位置
          newendposition = newstartposition + searchtxt.gettext().length();
          filechoose.tp2.select(newstartposition, newendposition);//找到文本,選擇文本
    }

替換

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if(filechoose.focus == 1){
          filechoose.tp1.requestfocus(true);
          str = filechoose.tp1.gettext();
          startposition = str.indexof(searchtxt.gettext());
          endposition = startposition + searchtxt.gettext().length();
          filechoose.tp1.replaceselection(replacetxt.gettext());
          newendposition = endposition;
        }else if(filechoose.focus == 2){
          filechoose.tp2.requestfocus(true);
          str = filechoose.tp2.gettext();
          startposition = str.indexof(searchtxt.gettext());
          endposition = startposition + searchtxt.gettext().length();
          filechoose.tp2.replaceselection(replacetxt.gettext());
          newendposition = endposition;
   }

替換下一處

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
if(filechoose.focus == 1){
          filechoose.tp1.requestfocus(true);
          nexttemp = newendposition;
          strall = filechoose.tp1.gettext();////////////////////////////////
          filechoose.tp1.select(nexttemp, strall.length());/////////////////////////////
          nextstr = filechoose.tp1.getselectedtext();
          newstartposition = nextstr.indexof(searchtxt.gettext()) + nexttemp;
          newendposition = newstartposition + searchtxt.gettext().length();
          filechoose.tp1.select(newstartposition, newendposition);
          filechoose.tp1.replaceselection(replacetxt.gettext());
        }else if(filechoose.focus == 2){
          filechoose.tp2.requestfocus(true);
          nexttemp = newendposition;
          strall = filechoose.tp2.gettext();
          filechoose.tp2.select(nexttemp,strall.length());
          nextstr = filechoose.tp2.getselectedtext();
          newstartposition = nextstr.indexof(searchtxt.gettext()) + nexttemp;
          newendposition =newstartposition + searchtxt.gettext().length();
          filechoose.tp2.select(newstartposition, newendposition);
          filechoose.tp2.replaceselection(replacetxt.gettext());
    }

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 天天天干天天天操 | 久久久久综合狠狠综合日本高清 | 在线国产一区 | 欧美精品久久久 | 国产啊v在线观看 | 成人亚洲天堂 | 色婷婷综合久久久中文字幕 | 精品国产不卡一区二区三区 | 一区二区色 | 免费视频国产 | 久久人人爽人人爽人人片亚洲 | 自拍视频网站 | 操操日日 | 一级片欧美 | 一大道一二三区不卡 | 久久精品国产一区二区三区 | 国产一区二区三区久久 | 国产一区二区三区在线 | www.av在线播放| 婷婷天堂 | 免费裸体无遮挡黄网站免费看 | 精品美女一区 | 国产精品久久久久aaaa九色 | 青青草网站 | 国产精品一区三区 | 日本一区二区高清视频 | 波多野结衣一区二区三区中文字幕 | 日韩精品视频在线 | 在线观看亚洲 | 日韩午夜影院 | 一级毛片免费观看 | 99久久久国产精品 | 亚洲精品福利 | 一区二区三区国产好的精 | 久久91久久久久麻豆精品 | 91久久精品一区二区二区 | 日本不卡在线观看 | 看毛片网站 | 日韩精品在线免费观看 | 免费久草| 中文字幕大全 |