Loading...

          java .net

          需要寫個正則替換字符,網上找來個入門教程,很實用

          正則表達式30分鐘入門教程

          posted @ 2008-08-26 22:07 豬 閱讀(120) | 評論 (0)編輯 收藏
          select * from (select * from apply_info order by dbms_random.value) where rownum <= 3
          posted @ 2008-08-26 22:07 豬 閱讀(146) | 評論 (0)編輯 收藏

          Java語言: 臨時自用代碼@代碼發芽網
          01 public class Test {
          02 /**
          03 * Simplest in Java 1.5, using the replace method, which
          04 * takes CharSequence objects.
          05 */
          06 public static String replace15(
          07     String aInput, String aOldPattern, String aNewPattern){
          08     return aInput.replace(aOldPattern, aNewPattern);
          09 }
          10 /**
          11 * Not quite as simple in Java 1.4. The replaceAll method works,
          12 * but requires more care, since it uses regular expressions, which
          13 * may contain special characters.
          14 */
          15 public static String replace14(
          16     String aInput, String aOldPattern, String aNewPattern){
          17     /*
          18     * The replaceAll method is a bit dangerous to use.
          19     * The aOldPattern is converted into a regular expression.
          20     * Thus, if aOldPattern may contain characters which have
          21     * special meaning to regular expressions, then they must
          22     * be 'escaped' before being passed to replaceAll. It is
          23     * easy to forget to do this.
          24     *
          25     * In addition, aNewPattern treats '$' as special characters
          26     * as well: they refer to 'back references'.
          27     */
          28     return aInput.replaceAll(aOldPattern, aNewPattern);
          29     /*
          30     Here is an alternative implementation using Pattern and Matcher,
          31     which is preferred when the same pattern is used repeatedly
          32     final Pattern pattern = Pattern.compile( aOldPattern );
          33     final Matcher matcher = pattern.matcher( aInput );
          34     return matcher.replaceAll( aNewPattern );
          35     */
          36 }
          37 /**
          38 * If Java 1.4 is unavailable, the following technique may be used.
          39 *
          40 * @param aInput is the original String which may contain substring aOldPattern
          41 * @param aOldPattern is the non-empty substring which is to be replaced
          42 * @param aNewPattern is the replacement for aOldPattern
          43 */
          44 public static String replaceOld(
          45     final String aInput,
          46     final String aOldPattern,
          47     final String aNewPattern){
          48      if ( aOldPattern.equals("") ) {
          49         throw new IllegalArgumentException("Old pattern must have content.");
          50      }
          51      final StringBuffer result = new StringBuffer();
          52      //startIdx and idxOld delimit various chunks of aInput; these
          53      //chunks always end where aOldPattern begins
          54      int startIdx = 0;
          55      int idxOld = 0;
          56      while ((idxOld = aInput.indexOf(aOldPattern, startIdx)) >= 0) {
          57        //grab a part of aInput which does not include aOldPattern
          58        result.append( aInput.substring(startIdx, idxOld) );
          59        //add aNewPattern to take place of aOldPattern
          60        result.append( aNewPattern );
          61        //reset the startIdx to just after the current match, to see
          62        //if there are any further matches
          63        startIdx = idxOld + aOldPattern.length();
          64      }
          65      //the final chunk will go to the end of aInput
          66      result.append( aInput.substring(startIdx) );
          67      return result.toString();
          68 }
          69 /** Example: update an ip address appearing in a link. */
          70 public static void main (String[] aArguments) {
          71     String OLD_IP = "insert into LOAD_POLIINFO (IDCARD,POLISTAT,JOINDATE,LOADNO) values ('110102197906300508','13',to_date('null ','yyyy-mm-dd'),70990)";
          72 log(replaceOld(OLD_IP,"to_date('null ','yyyy-mm-dd')","null"));
          73 }
          74 private static void log(String aMessage){
          75     System.out.println(aMessage);
          76 }
          77 }

          參考自:http://www.javapractices.com/topic/TopicAction.do?Id=80

                       http://biostar.blog.sohu.com/69732830.html

          posted @ 2008-08-26 22:07 豬 閱讀(618) | 評論 (0)編輯 收藏
          養一群地震局“專家”,不如養一群蛤蟆
          posted @ 2008-08-26 22:06 豬 閱讀(118) | 評論 (0)編輯 收藏

          import java.util.*;

          public class Test
          {
          public static void main(String[] agrs)
          {
             int[] allIdList = new int[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
             int[] randomIdList = new Test().getRandomIdList(allIdList,10);
             for(int randomIdList_index = 0;randomIdList_index < randomIdList.length;randomIdList_index++){
              System.out.println(randomIdList[randomIdList_index]);
             }
          }


          /**
          *
          * @author liuzhaochun
          * @explain:從指定的數組中隨機取count個,返回這個數組
          * @datetime:2008-5-9
          * @return
          * @return int [] 包含隨機取的count個值的數組
          */
          public int[] getRandomIdList(int[] allIdList,int count){
            
             int[] randomIdList = new int[count];
             int randomIdList_index = 0;
             for(int allIdList_index = allIdList.length - 1; randomIdList_index < count;allIdList_index--,randomIdList_index++){
              int temp_Index = (int)(Math.random() * allIdList_index);
              randomIdList[randomIdList_index] = allIdList[temp_Index];
              allIdList[temp_Index] = allIdList[allIdList_index];
             }
             return randomIdList;
          }



          }

          posted @ 2008-08-26 22:06 豬 閱讀(464) | 評論 (0)編輯 收藏
          class Program
              {
                  static void Main(string[] args)
                  {
                      Console.WriteLine(Next("abc123def345ghi"));
                      Console.Read();

                  }

                  private static string Next(string s)
                  {
                      if (!isNumber(s.Substring(s.Length-1,1)))
                          s = s + "0";
                      MatchCollection coll = Regex.Matches(s, @"\d+");
                      Match m = coll[coll.Count - 1];

                      return s.Substring(0, m.Index) + NextNum(m.Value);
                  }
                  private static string NextNum(string s)
                  {
                      char[] cs = s.ToCharArray();
                      for (int i = s.Length - 1; i >= 0; i--)
                      {
                          if (!NextChar(ref   cs[i])) break;
                      }
                    
                      string re = new string(cs);
                      if (Int32.Parse(re) == 0)
                          re = "1" + re;
                      return re;
                  }
                  private static bool NextChar(ref   char c)
                  {
                      string p = "01234567890123456789";
                      int n = p.IndexOf(c);
                      c = p[(n + 1) % 10 + 10 * (n / 10)];
                      return (n == 9 || n == 19);
                  }
                  public static bool isNumber(string str)
                  {
                      Regex r = new Regex(@"^\d+(\.)?\d*$");
                      if (r.IsMatch(str))
                      {
                          return true;
                      }
                      else
                      {
                          return false;
                      }
                  }
          posted @ 2008-08-26 22:06 豬 閱讀(814) | 評論 (0)編輯 收藏

          今兒咱民工真高產,勞動節了嘛,哈哈

          真的希望像我那頭豬一樣啊,呵呵

          睡吧,明天太陽會升起

          不對,今天的太陽就要升起 呵呵

          咯色的垃圾

          咯色的垃圾就應該扔到無人煙的垃圾堆里,愛咋咋地去,省的惹別人一身臭

          大家離我遠點

          posted @ 2008-08-26 22:06 豬 閱讀(98) | 評論 (0)編輯 收藏

          我遇到什么事不能解決就慌亂,心煩,跟他娘的女人來事兒似的,呵呵,據說是

          更不用說,幾件事壓在頭上了

          能夠坦然的,游刃有余的處理來自各方的瑣事,可能就是比較高的人了吧,呵呵

          想想,周末好像有成為黑色的趨勢,聽著老婆不時的嘮叨妹妹的這啊那啊的,不知如何是好

          小系統做了半年多還沒結項,開始喪失在大大那的賞識

          并且占用了我所有的業余時間,老婆都要跑了

          而且老扯票撒謊的出去,心都虛了,每次要編個瞎話跟他娘的下地獄似的,痛苦

          太嫩....

          posted @ 2008-08-26 22:06 豬 閱讀(229) | 評論 (0)編輯 收藏

          認識我的人大都說我變了

          我難以判定,好像是變了,變怎么了?不知道,大多說我變垃圾了

          開始時,看電視也好,電影也好,故事也好,兩個人吵架,大都是因為互相不理解,有未言明的誤會,吵啊吵的不可開交,甚至不可挽回,那時我就告訴自己,遇到這樣的事一定要,立刻解釋清楚,靜下心來坦言,消除了誤會,讓對方理解了,也就好了。而現在,我很不想去解釋,想的是如果言明了就沒意思了,唉...可能也不能一概而論,可能也要分什么事情,可能也分什么關系的人,有默契的人可能就不用解釋

          人啊,郁悶而又閑閑的時候就容易胡思亂想。

          posted @ 2008-08-26 22:06 豬 閱讀(108) | 評論 (0)編輯 收藏

          發現如果某人惹你不高興了,一段時間內,你看他哪都不順眼,呵呵

          北京人兒啊,都那么自信,自信的讓人都只能隱形了

          只知道讓人干活的公司會是什么樣?就像老一輩講求無私奉獻,為實現共產而努力奮斗,呵呵,我們得到什么了呢,老一輩還得到精神上的滿足,我們連精神上的都沒了,加班費都不好好給報了,我日啊,老子是喜歡錢地。

          開始羨慕民工了,呵呵,

          可咱翅膀還沒長硬,忍著吧

          學習 學習 學習

          posted @ 2008-08-26 22:06 豬 閱讀(109) | 評論 (0)編輯 收藏

          心情不好時就抽煙,喝酒,可命的抽,昨晚瀏覽了個電影,韓國的,一帥哥愛喝酒抽煙,得了肝硬化,放下身邊的工作,媽媽,女友,去療養院了。呵呵,難道韓國有這樣的規定?在我的世界不知道誰能做到去療養院,能去醫院看看,聽醫囑,就是有條件的了。

          從地鐵出來都十一點了,看著外面一個個擺攤賣玉米的,等活兒的出租車司機,人活著比他媽狗都難。

          今天公司聚餐,老總說她別看那么大歲數了,可比我們健康,讓我們一定要注意身體,她每周都至少在健身房呆兩個小時,呵呵,不是一個階層的人啊,俺倒想去健身房,俺還沒房住呢,咋整...

          唉...內外兼憂啊

          posted @ 2008-08-26 22:06 豬 閱讀(121) | 評論 (0)編輯 收藏

          好像從開始上大學開始有五一放假這一說,大學時候的放假忘了都干啥了,只記得剛上大一的第一個十一是自己一個人在宿舍過的,大家都回家了。

          畢業后的五一都該成我的受難日了,呵呵

          勞動節?

          posted @ 2008-08-26 22:06 豬 閱讀(131) | 評論 (0)編輯 收藏

          今天晚上花2塊錢16*2站地,大半個北京了,剛回來,可累死了,還好趕上了末班車,要不就慘了,身上就10塊錢,在這里祝她老爺子生日快樂,呵呵,雖然人家用不著...

          posted @ 2008-08-26 22:06 豬 閱讀(129) | 評論 (0)編輯 收藏

          我這么個鳥人,自己都沒辦法,唉...

          懦弱,咯色,孤僻,小人,虛榮,膽怯,庸俗,冷血

          posted @ 2008-08-26 22:06 豬 閱讀(103) | 評論 (0)編輯 收藏
          被忽悠了呵呵,謝謝

          啥是法兒
          今兒累壞了,上午改那該死的bug,下午急匆匆跑了趟前門,剛到就公司打電話找,真他娘的倒霉,又急急忙忙敢了回來,干活,下班了,打個電話吧,呵呵,才知道原來是被忽悠了一天,唉...啥是法兒,還是那么地,只能怪自己,回家吧,呵呵
          對了,今天騎的自行車,發現也不比原來遠多少,當初怎么就沖動買了電動車呢,下了班,慢慢悠悠騎回來了,唉...想想會有回家的勁兒,一個人都沒有,都是自個作地,受吧。

          唉...最近不順,沒啥精神事兒

          五一了,呵呵 ,又
          posted @ 2008-08-26 22:06 豬 閱讀(111) | 評論 (0)編輯 收藏
          僅列出標題
          共27頁: First 上一頁 4 5 6 7 8 9 10 11 12 下一頁 Last 

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 上杭县| 深圳市| 界首市| 黎城县| 邳州市| 上饶市| 德令哈市| 临沂市| 龙里县| 泰兴市| 梅州市| 内江市| 都江堰市| 台中县| 天峻县| 女性| 玛纳斯县| 额敏县| 淳化县| 永善县| 芦山县| 婺源县| 龙海市| 高碑店市| 芒康县| 乃东县| 西峡县| 河津市| 开江县| 万安县| 苍南县| 察隅县| 临安市| 三穗县| 忻州市| 漳州市| 湖北省| 哈密市| 舟山市| 竹山县| 湖南省|