regex
  • ant
  • 2017-10-06 72 views 0 likes 
    0

    我想在文件中匹配時替換列表。我有這樣的代碼:replaceregexp ant沒有插入列表

    <property name="line.separator" location="\r" /> 
    <property name="tab.separator" location="\t" /> 
    
    <target name="replace"> 
        <replaceregexp 
         match='@WebMethod([\s\S]*?(?=public))public\s+(\w+)\s+(\w*)[\s\S]+?(?=\))[\s\S]+?(?=MSE)(\w+)\s+(\w*)[\s\S+]+?(?=throws)throws\s+(\w*)' 
         replace='@WebMethod(operationName="\$4")${line.separator}${tab.separator}@RequestWrapper(localName = "\$3")${line.separator}\[email protected](localName = "\$2")${line.separator}\rpublic \$2 \$3\(${line.separator}\r\r\$4 \$5)${line.separator}\r\rthrows MSFWebServiceException' flags="g,m"> 
         <fileset dir="${project.dir}" /> 
        </replaceregexp> 
    

    但 @WebMethod(operationName = 「\ $ 4」)的部分$ {line.separator}${tab.separator}@RequestWrapper

    回報這樣的:

    @WebMethod(operationName="MSEPDetalleFigPartDTO") 
    C:[email protected] 
    

    所以\ n趨向正常,但由於它替換爲C \ T中的\ t不起作用:T,而不是一個列表。

    任何幫助將不勝感激。

    最親切的問候

    回答

    0

    這是location而不是value\t原因,而不是&#x9;

    <property name="tab.separator" location="\t" /> 
    

    ,而不是

    <property name="tab.separator" value="&#x9;" /> 
    

    酒店line.separator已經設置(因爲它是一個Ant built-in property),所以你的第一行被忽略。

    location="\t"意味着在根目錄下的文件t的文件的位置,你的情況是驅動C:

    相關問題