最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Groovy/Java - 復(fù)制文件路徑中帶有括號(hào)的問題

Groovy/Java - 復(fù)制文件路徑中帶有括號(hào)的問題

慕尼黑8549860 2023-02-23 10:49:27
我目前有一個(gè)腳本,通過正則表達(dá)式包含和排除將文件從源目錄復(fù)制到目標(biāo)目錄,但是當(dāng)路徑包含括號(hào)時(shí),文件將不會(huì)復(fù)制。我最初的想法是,問題在于如何讀取源和目標(biāo),因?yàn)?( 是一個(gè)特殊字符,為了對(duì)抗我試圖用轉(zhuǎn)義的 (,但我可能做錯(cuò)了那部分。import groovy.io.FileTypeimport java.nio.file.*    String Source = 'C:/temp/file(s)'    String Target = 'C:/newTemp/file(s)'    String InclusionsRegexes = "garbage.txt"    String ExclusionsRegexes = ""    class RegexInfo    {        private String AllRegexes = "";        public RegexInfo(String RegexString, String RegexType, String Source)        {            if(RegexString != null)            {                def RegexArray = RegexString.split(",");                for(item in RegexArray)                {                    String fullRegexPath = Source + "/" + item;                    if(AllRegexes != null && !AllRegexes.isAllWhitespace())                    {                        //Add regex value for Or                        AllRegexes += "|";                    }                    AllRegexes += fullRegexPath;                }            }        }        public String getAllRegexes() { return this.AllRegexes; }    }    IncludesRegexInfo = new RegexInfo(InclusionsRegexes, "inclusion", Source);    ExcludesRegexInfo = new RegexInfo(ExclusionsRegexes, "exclusion", Source);    File SourceDirToCopy = new File(Source);    SourceDirToCopy.eachFileRecurse()    {        SourceFile ->        String SourceFilePath = SourceFile.toString().replaceAll("\\\\","/");        if(SourceFile.isDirectory())        {            SourceFilePath += "/"        }我收到的錯(cuò)誤要么是意外字符,要么是文件沒有錯(cuò)誤地移動(dòng)。
查看完整描述

1 回答

?
慕姐8265434

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊

if(SourceFilePath.matches(IncludesRegexInfo.getAllRegexes() && !SourceFilePath.matches(ExcludesRegexInfo.getAllRegexes()))為了解決腳本不復(fù)制的問題, “匹配”兩個(gè)字符串時(shí)出現(xiàn)問題。

字符串讀取為相同的行但是在正則表達(dá)式方面不匹配。要解決此問題,您必須(轉(zhuǎn)義. 這是用一個(gè))ExcludesRegexInfo.getAllRegexes().replaceAll("\\(","\\\\(").replaceAll("\\)","\\\\)")


查看完整回答
反對(duì) 回復(fù) 2023-02-23
  • 1 回答
  • 0 關(guān)注
  • 163 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)