亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: 對(duì)java代碼注釋的刪除 [打印本頁]

作者: way030724    時(shí)間: 2009-06-18 20:51
標(biāo)題: 對(duì)java代碼注釋的刪除
代碼注釋刪除,請(qǐng)高手幫忙

例如:ceshi.java

/**
* [email={@.en]{@.en[/email] Feature is father class of all the feature implementations, every feature
* hide, destroy.} [email={@.ja]{@.ja[/email] }
*
* [email={@.en]{@.en[/email] Feature is father class of all the feature implementations, every feature
* hide, destroy.} [email={@.ja]{@.ja[/email] skdjflsjdflkdjslfsjdkjflskdjfksjdlfjsldkjflksjdlkjflkjsldjflksjdsdf
* sdfdsfsdfsdfsdfsd }
*
* [email=*{@.ja]{@.ja[/email] jslkdjflkdsjlkfjldskjfkjdslfkjlsdkjflkdsjlkfjdslkjflkdsjlfkjsdlkfjslkdjflksjdlkfjsldkjfdf
* sdfsdfdsfsdfsdfsddfsdfsfdsdfsdfsdddddddddddddddddddddddddddddddddddddddd
* sdfdsfsf  }
*
* [email={@.en]{@.en[/email] Feature is father }
*
        public void hide(Hashtable paraTable) {
                currentFM.hideFeature(this, paraTable);
        }
}

規(guī)則為:1. 刪除掉 [email={@.ja]{@.ja[/email] 與 緊鄰下一個(gè) } 和 之間的內(nèi)容,包括這之間的描述。
          2. 刪除掉 [email={@.en]{@.en[/email] 與 緊鄰下一個(gè) } ,保留這之間的英文內(nèi)容。

希望得到的運(yùn)行結(jié)果為:

/**
* Feature is father class of all the feature implementations, every feature
* hide, destroy.
*
* [email={@Feature]Feature[/email] is father class of all the feature implementations, every feature
* hide, destroy.
*
* [email={@Feature]Feature[/email] is father
*
        public void hide(Hashtable paraTable) {
                currentFM.hideFeature(this, paraTable);
        }
}


先行謝過拉:)
作者: way030724    時(shí)間: 2009-06-18 21:01
標(biāo)題: 回復(fù) #1 way030724 的帖子
帶 地址符號(hào) '@' 問題就出錯(cuò)了


下面是重發(fā)的問題:

代碼注釋刪除,請(qǐng)高手幫忙

例如:ceshi.java

/**
* {en Feature is father class of all the feature implementations, every fea
* hide, destroy.} {ja }
*
* {en Feature is father class of all the feature implementations, every feature
* hide, destroy.} {ja skdjflsjdflkdjslfsjdkjflskdjfksjdlfjsldkjflksjdlkjflkjsldjflksjdsdf
* sdfdsfsdfsdfsdfsd }
*
* {ja jslkdjflkdsjlkfjldskjfkjdslfkjlsdkjflkdsjlkfjdslkjflkdsjlfkjsdlkfjslkdjflksjdlkfjsldkjfdf
* sdfsdfdsfsdfsdfsddfsdfsfdsdfsdfsdddddddddddddddddddddddddddddddddddddddd
* sdfdsfsf  }
*
* {en Feature is father }
*
        public void hide(Hashtable paraTable) {
                currentFM.hideFeature(this, paraTable);
        }
}

規(guī)則為:1. 刪除掉 {ja 與 緊鄰下一個(gè) } 和 之間的內(nèi)容,包括這之間的描述。
          2. 刪除掉 {en 與 緊鄰下一個(gè) } ,保留這之間的英文內(nèi)容。

希望得到的運(yùn)行結(jié)果為:

/**
* Feature is father class of all the feature implementations, every feature
* hide, destroy.
*
* Feature is father class of all the feature implementations, every feature
* hide, destroy.
*
* Feature is father
*
        public void hide(Hashtable paraTable) {
                currentFM.hideFeature(this, paraTable);
        }
}


先行謝過拉:)
作者: lululau    時(shí)間: 2009-06-18 21:13
你這注釋怎么沒有結(jié)束的地方?
作者: way030724    時(shí)間: 2009-06-18 21:21
標(biāo)題: 回復(fù) #3 lululau 的帖子
不好意思啊,我不是編寫java的,自己寫了點(diǎn)代碼,呵呵

/**
* {en Feature is father class of all the feature implementations, every fea
* hide, destroy.} {ja }
*
* {en Feature is father class of all the feature implementations, every feature
* hide, destroy.} {ja skdjflsjdflkdjslfsjdkjflskdjfksjdlfjsldkjflksjdlkjflkjsldjflksjdsdf
* sdfdsfsdfsdfsdfsd }
*
* {ja jslkdjflkdsjlkfjldskjfkjdslfkjlsdkjflkdsjlkfjdslkjflkdsjlfkjsdlkfjslkdjflksjdlkfjsldkjfdf
* sdfsdfdsfsdfsdfsddfsdfsfdsdfsdfsdddddddddddddddddddddddddddddddddddddd dd
* sdfdsfsf  }
*
* {en Feature is father }
*
**/

        public void hide(Hashtable paraTable) {
                currentFM.hideFeature(this, paraTable);
        }
}
作者: lululau    時(shí)間: 2009-06-18 21:37

  1. liuxiang@MacBookPro: ~ $ echo '
  2. /**
  3. * {en Feature is father class of all the feature implementations, every fea
  4. * hide, destroy.} {ja }
  5. *
  6. * {en Feature is father class of all the feature implementations, every feature
  7. * hide, destroy.} {ja skdjflsjdflkdjslfsjdkjflskdjfksjdlfjsldkjflksjdlkjflkjsldjflksjdsdf
  8. * sdfdsfsdfsdfsdfsd }
  9. *
  10. * {ja jslkdjflkdsjlkfjldskjfkjdslfkjlsdkjflkdsjlkfjdslkjflkdsjlfkjsdlkfjslkdjflksjdlkfjsldkjfdf
  11. * sdfsdfdsfsdfsdfsddfsdfsfdsdfsdfsdddddddddddddddddddddddddddddddddddddddd
  12. * sdfdsfsf  }
  13. *
  14. * {en Feature is father }
  15. *
  16.         public void hide(Hashtable paraTable) {
  17.                 currentFM.hideFeature(this, paraTable);
  18.         }
  19. }' | perl -e '
  20. > while(<>){
  21. > $text .= $_;
  22. > }
  23. > $text =~ s/\{ja.*?\}//gs;
  24. > $text =~ s/\{en(.*?)\}/$1/gs;
  25. > print $text;'

復(fù)制代碼


試試這個(gè),可能會(huì)有多余空行
作者: way030724    時(shí)間: 2009-06-18 21:57
原帖由 lululau 于 2009-6-18 21:37 發(fā)表

liuxiang@MacBookPro: ~ $ echo '
/**
* {en Feature is father class of all the feature implementations, every fea
* hide, destroy.} {ja }
*
* {en Feature is father class of all the feature i ...


比預(yù)想的只多了一行,就像{ja jdskjfkds} 如果跨行的話,只保留一行。對(duì)吧?
下面是執(zhí)行的結(jié)果,非常感謝

> print $text;'
/**
*  Feature is father class of all the feature implementations, every fea
* hide, destroy.
*
*  Feature is father class of all the feature implementations, every feature
* hide, destroy.
*
*
*
*  Feature is father
*
        public void hide(Hashtable paraTable) {
                currentFM.hideFeature(this, paraTable);
        }
}
作者: lululau    時(shí)間: 2009-06-18 22:10
不知道你的代碼格式規(guī)范不?
如果你能保證所有的只有一個(gè)*號(hào)的注釋行都頂在行首的話:


  1. perl -e '
  2. > while(<>){
  3. > $text .= $_;
  4. > }
  5. > $text =~ s/\{ja.*?\}//gs;
  6. > $text =~ s/\{en(.*?)\}/$1/gs;
  7. > $text =~ s/(\*\s*\n)+/$1/gs;
  8. > print $text;'
復(fù)制代碼

作者: lululau    時(shí)間: 2009-06-18 22:11
阿,不好意思,一般來說,對(duì)于正常的Java代碼,我的這個(gè)假設(shè)根本不成立阿
作者: lululau    時(shí)間: 2009-06-18 22:13

  1. perl -e '
  2. > while(<>){
  3. > $text .= $_;
  4. > }
  5. > $text =~ s/\{ja.*?\}//gs;
  6. > $text =~ s/\{en(.*?)\}/$1/gs;
  7. > $text =~ s/([ \t]*\*\s*\n)+/$1/gs;
  8. > print $text;'
復(fù)制代碼


應(yīng)該沒問題了
作者: way030724    時(shí)間: 2009-06-18 22:32
標(biāo)題: 回復(fù) #9 lululau 的帖子
標(biāo)準(zhǔn)的*號(hào) 前面還有個(gè)空格的吧? 我在試腳本,有問題了我再給你留言吧
作者: ly5066113    時(shí)間: 2009-06-19 09:08
sed '/\/\*/{:a;N;/*\//!ba;s/{ja[^}]*}//g;s/{en\([^}]*\)}/\1/g}' urfile
作者: way030724    時(shí)間: 2009-06-19 22:07
原帖由 ly5066113 于 2009-6-19 09:08 發(fā)表
sed '/\/\*/{:a;N;/*\//!ba;s/{ja[^}]*}//g;s/{en\([^}]*\)}/\1/g}' urfile


回復(fù)的有點(diǎn)晚了,剛洗了個(gè)澡,把自己機(jī)器上的linux 虛擬調(diào)通,呵呵。
下面是我測(cè)試的結(jié)果:
[root@localhost ceshi]# cat -n ceshi.txt
     1  /**
     2   * {en 11111111111111111111111111111 } {ja 22222222}
     3   * {ja }
     4   * {en 111111111111111111111111
     5   * 111111111}
     6   * {en 1111111111111111} {ja qqqqqqqqq
     7   * sssssssssssssssssssssssssssssssssssssss
     8   * wwwww}
     9   *
    10   **/
    11     public void hide(hsdihfoshdo) {
    12              currentFM.hideFeature()
    13     }
[root@localhost ceshi]# sed '/\/\*/{:a;N;/*\//!ba;s/{ja[^}]*}//g;s/{en\([^}]*\)}/\1/g}' ceshi.txt | cat -n
     1  /**
     2   *  11111111111111111111111111111  
     3   *
     4   *  111111111111111111111111
     5   * 111111111
     6   *  1111111111111111
     7   *
     8   **/
     9     public void hide(hsdihfoshdo) {
    10              currentFM.hideFeature()
    11     }
[root@localhost ceshi]#
正是期望的結(jié)果吧,感激阿
下來一定要好好學(xué)正則表達(dá)式了,我只會(huì)一般的操作。
作者: chinaglwo    時(shí)間: 2009-06-20 22:56
原帖由 ly5066113 于 2009-6-19 09:08 發(fā)表
sed '/\/\*/{:a;N;/*\//!ba;s/{ja[^}]*}//g;s/{en\([^}]*\)}/\1/g}' urfile



老大,能否解釋一下這幾個(gè)命令
:a
N
/*\//!ba

N我知道是允許跨行的模式匹配

先謝謝




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2