-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
812 lines (428 loc) · 30.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>Alvin</title>
<meta name="author" content="Alvin">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://freealvin.github.io">
<link href="/favicon.png" type="image/png" rel="icon">
<link href="/atom.xml" rel="alternate" title="Alvin" type="application/atom+xml">
<script src="/javascripts/libs/jquery/jquery-2.0.3.min.js"></script>
<link href="/assets/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-44223318-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body >
<div id="wrap">
<header role="banner">
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Alvin</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">
<a href="/">Blog</a>
</li>
<li >
<a href="/blog/archives">Archives</a>
</li>
<li >
<a href="/about">About</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a class="subscribe-rss" href="/atom.xml" title="subscribe via RSS">
<span class="visible-xs">RSS</span>
<img class="hidden-xs" src="/images/rss.png" alt="RSS">
</a>
</li>
</ul>
<form class="search navbar-form navbar-right" action="https://www.google.com/search" method="GET">
<input type="hidden" name="q" value="site:freealvin.github.io">
<div class="form-group">
<input class="form-control" type="text" name="q" placeholder="Search">
</div>
</form>
</div>
</div>
</nav>
</header>
<div id="main" class="container">
<div id="content">
<div class="row">
<div class="page-content col-md-9">
<meta itemprop="name" content="Alvin" />
<meta itemprop="description" content="" />
<meta itemprop="url" content="http://freealvin.github.io" />
<div class="blog-index" itemscope itemtype="http://schema.org/Blog">
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2015-04-13T01:55:00+08:00" data-updated="true" itemprop="datePublished dateCreated">Apr 13<sup>th</sup>, 2015</time>
| <a href="/blog/2015/04/13/javacan-shu-chuan-di/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2015/04/13/javacan-shu-chuan-di/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2015/04/13/javacan-shu-chuan-di/" itemprop="url">Java参数传递</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><p>参数传递分为值传递和引用传递,Java是面向对象的编程语言,又是如何传递参数的呢?</p>
</div>
<footer>
<a class="btn btn-default" href="/blog/2015/04/13/javacan-shu-chuan-di/">more →</a>
</footer>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2015-04-11T08:32:47+08:00" data-updated="true" itemprop="datePublished dateCreated">Apr 11<sup>th</sup>, 2015</time>
| <a href="/blog/2015/04/11/java-lei-de-finalyin-yong-cheng-yuan-shi-li/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2015/04/11/java-lei-de-finalyin-yong-cheng-yuan-shi-li/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2015/04/11/java-lei-de-finalyin-yong-cheng-yuan-shi-li/" itemprop="url">Java 类的final引用成员实例</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><p>final修饰符大都用于基本类型,或不可变类的域(如果类中的每个方法都不会改变其对象,这种类就是不可变的类。例如,String类就是一个不可变的类)。对于可变的类使用final修饰符可能会对读者造成混乱。例如,private final Date hiredate;</p>
<p>仅仅意味着存储在hiredate变量中的<em>对象引用</em>在对象构造之后不能被改变,而不意味着hiredate对象是一个常量。任何方法都可以对hiredate引用的对象调用setTime更改器。</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="kn">package</span> <span class="n">per</span><span class="o">.</span><span class="na">alvin</span><span class="o">.</span><span class="na">demos</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">User</span> <span class="o">{</span>
</span><span class='line'>
</span><span class='line'> <span class="kd">private</span> <span class="n">String</span> <span class="n">name</span><span class="o">;</span>
</span><span class='line'> <span class="kd">private</span> <span class="kt">int</span> <span class="n">age</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'> <span class="kd">public</span> <span class="nf">User</span><span class="o">(){</span>
</span><span class='line'>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="kd">public</span> <span class="nf">User</span><span class="o">(</span><span class="n">String</span> <span class="n">name</span><span class="o">,</span> <span class="kt">int</span> <span class="n">age</span><span class="o">){</span>
</span><span class='line'> <span class="k">this</span><span class="o">.</span><span class="na">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">;</span>
</span><span class='line'> <span class="k">this</span><span class="o">.</span><span class="na">age</span> <span class="o">=</span> <span class="n">age</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'>
</span><span class='line'> <span class="kd">public</span> <span class="n">String</span> <span class="nf">getName</span><span class="o">()</span> <span class="o">{</span>
</span><span class='line'> <span class="k">return</span> <span class="n">name</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">setName</span><span class="o">(</span><span class="n">String</span> <span class="n">name</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="k">this</span><span class="o">.</span><span class="na">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="kd">public</span> <span class="kt">int</span> <span class="nf">getAge</span><span class="o">()</span> <span class="o">{</span>
</span><span class='line'> <span class="k">return</span> <span class="n">age</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">setAge</span><span class="o">(</span><span class="kt">int</span> <span class="n">age</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="k">this</span><span class="o">.</span><span class="na">age</span> <span class="o">=</span> <span class="n">age</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="kn">package</span> <span class="n">per</span><span class="o">.</span><span class="na">alvin</span><span class="o">.</span><span class="na">demos</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Item</span> <span class="o">{</span>
</span><span class='line'> <span class="kd">private</span> <span class="kd">final</span> <span class="n">User</span> <span class="n">user</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'> <span class="kd">public</span> <span class="nf">Item</span><span class="o">(</span><span class="n">User</span> <span class="n">user</span><span class="o">){</span>
</span><span class='line'> <span class="k">this</span><span class="o">.</span><span class="na">user</span> <span class="o">=</span> <span class="n">user</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="kd">public</span> <span class="n">User</span> <span class="nf">getUser</span><span class="o">()</span> <span class="o">{</span>
</span><span class='line'> <span class="k">return</span> <span class="n">user</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'>
</span><span class='line'> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span> <span class="o">[]</span> <span class="n">arags</span><span class="o">){</span>
</span><span class='line'> <span class="n">User</span> <span class="n">alvin</span> <span class="o">=</span> <span class="k">new</span> <span class="n">User</span><span class="o">(</span><span class="s">"alvin"</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
</span><span class='line'> <span class="n">Item</span> <span class="n">item</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Item</span><span class="o">(</span><span class="n">alvin</span><span class="o">);</span>
</span><span class='line'>
</span><span class='line'> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">item</span><span class="o">.</span><span class="na">getUser</span><span class="o">().</span><span class="na">getName</span><span class="o">());</span>
</span><span class='line'> <span class="n">alvin</span><span class="o">.</span><span class="na">setName</span><span class="o">(</span><span class="s">"nathan"</span><span class="o">);</span>
</span><span class='line'> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">item</span><span class="o">.</span><span class="na">getUser</span><span class="o">().</span><span class="na">getName</span><span class="o">());</span>
</span><span class='line'>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
</div>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2015-04-08T19:30:59+08:00" data-updated="true" itemprop="datePublished dateCreated">Apr 8<sup>th</sup>, 2015</time>
| <a href="/blog/2015/04/08/unixhuan-jing-gao-ji-bian-cheng-zhi-jin-cheng-huan-jing/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2015/04/08/unixhuan-jing-gao-ji-bian-cheng-zhi-jin-cheng-huan-jing/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2015/04/08/unixhuan-jing-gao-ji-bian-cheng-zhi-jin-cheng-huan-jing/" itemprop="url">Unix环境高级编程之进程环境</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><p>当执行程序时,main函数是如何被调用的;命令行参数如何传送给程序;典型的存储器布局是什么样的;如何分配额外的存储空间;进程如何使用环境变量;不同进程的终止形式。</p>
<!--more--->
<h2>main函数</h2>
<p>当内核执行C程序时,在调用main前先调用一个特殊的启动例程。可执行文件将词启动例程指定微程序的起始位置——这由连接编辑器设置,而连接编辑器由C编译器调用,启动例程从内核获得命令行参数和环境变量。</p>
<h2>进程终止</h2>
<p>八种方式可以终止进程,5种为正常终止,它们是:
1.从main返回
2.调用exit
3.调用<em>exit或</em>EXIT
4.最后一个线程从其启动例程返回
5.最后一个线程调用pthread_exit</p>
<p>异常的终止方式有三种
6.调用abort
7.接到一个信号并终止
8.最后一个线程对取消请求做出相应</p>
</div>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2015-04-04T17:08:13+08:00" data-updated="true" itemprop="datePublished dateCreated">Apr 4<sup>th</sup>, 2015</time>
| <a href="/blog/2015/04/04/liu-ge-yue-hou/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2015/04/04/liu-ge-yue-hou/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2015/04/04/liu-ge-yue-hou/" itemprop="url">六个月后</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><p>六个月后重新找回Octopress开始写作的我,开始知道自己的未来的目标,精通java,阅读Mysql类的书,开始去真正了解分布式系统设计,向我的同学学习,了解机器学习。</p>
<p>我知道现在白天实习,晚上去抽时间学习比较累,但有目标的人心里总是有底的,我相信我能坚持。加油。</p>
</div>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2013-12-02T21:31:00+08:00" data-updated="true" itemprop="datePublished dateCreated">Dec 2<sup>nd</sup>, 2013</time>
| <a href="/blog/2013/12/02/cyu-yan-de-suo-jin-he-kong-bai/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2013/12/02/cyu-yan-de-suo-jin-he-kong-bai/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2013/12/02/cyu-yan-de-suo-jin-he-kong-bai/" itemprop="url">C语言的缩进和空白</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><p>C语言的缩进和空白使用原则</p>
</div>
<footer>
<a class="btn btn-default" href="/blog/2013/12/02/cyu-yan-de-suo-jin-he-kong-bai/">more →</a>
</footer>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2013-12-02T08:45:00+08:00" data-updated="true" itemprop="datePublished dateCreated">Dec 2<sup>nd</sup>, 2013</time>
| <a href="/blog/2013/12/02/at-and-thui-bian-yu-fa-2/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2013/12/02/at-and-thui-bian-yu-fa-2/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2013/12/02/at-and-thui-bian-yu-fa-2/" itemprop="url">AT&T汇编语法2</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><ol>
<li>内联汇编</li>
</ol>
</div>
<footer>
<a class="btn btn-default" href="/blog/2013/12/02/at-and-thui-bian-yu-fa-2/">more →</a>
</footer>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2013-11-27T09:14:00+08:00" data-updated="true" itemprop="datePublished dateCreated">Nov 27<sup>th</sup>, 2013</time>
| <a href="/blog/2013/11/27/at-and-thui-bian-yu-yan-xue-xi-1/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2013/11/27/at-and-thui-bian-yu-yan-xue-xi-1/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2013/11/27/at-and-thui-bian-yu-yan-xue-xi-1/" itemprop="url">AT&T汇编语言学习1</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"></div>
<footer>
<a class="btn btn-default" href="/blog/2013/11/27/at-and-thui-bian-yu-yan-xue-xi-1/">more →</a>
</footer>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2013-11-26T20:09:00+08:00" data-updated="true" itemprop="datePublished dateCreated">Nov 26<sup>th</sup>, 2013</time>
| <a href="/blog/2013/11/26/linuxzhong-de-zheng-ze-biao-da-shi/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2013/11/26/linuxzhong-de-zheng-ze-biao-da-shi/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2013/11/26/linuxzhong-de-zheng-ze-biao-da-shi/" itemprop="url">Linux中的正则表达式</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><!--more about 正则表达式-->
<h1>正则表达式</h1>
<br />
<pre><code>正则表达式完成字符串的匹配搜索,在Unix系统中,sed、grep、vi等工具都是用regexp规则。
(1) 正则表达式的基本语法
| 符号 | 含义 | 举例 | 匹配 |
| --------------- | ---------------------------------------- | -------------------- | -------------------------- |
| . | 任何字符 | a.. | a后面有两个字符的字符串 |
| ? | 修饰匹配次数,0次或1次 | x? | 0个或1个x |
| ^ | 匹配行首 | ^word | 位于行首的word |
| + | 重复一次或多次 | y+ | 一个--或多个连续的y |
| $ | 行尾 | x$ | 以x结尾的行 |
| * | 重复0次或多次 | w.*s | 以w开头、s结尾的任何字符串 |
| [字符表] | 字符表中的任一字符 | [tT] | 小写字母t或大写字母T |
| [!字符表] | 匹配不属于范围指定内的字符 | [!a-z] | 匹配不是小写字母的字符 |
| [^字符表] | 任一不在字符表中的字符 | [^a-z A-Z] | 任何非字母 |
| \ | 转义字符 | \\n | 匹配换行符 |
| \{min,max\} | 前导正则表达式最少重复min次,最多重复max次 | x\{1,5\} | 最少1个最多5个x |
| \(...\) | 将圆括号中匹配的字符串存储到下一个寄存器中 | \(more\)and\1 | 匹配more and more |
| 表达式|1表达式2 | 匹配表达式1或表达式2 | hello| happy | 匹配hello或happy |
</code></pre>
</div>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2013-11-18T00:35:00+08:00" data-updated="true" itemprop="datePublished dateCreated">Nov 18<sup>th</sup>, 2013</time>
| <a href="/blog/2013/11/18/ruby-on-rails-with-mongodb/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2013/11/18/ruby-on-rails-with-mongodb/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2013/11/18/ruby-on-rails-with-mongodb/" itemprop="url">Ruby on Rails With Mongodb</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description">
</div>
</article>
<article class="post" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<header class="page-header">
<p class="meta text-muted text-uppercase">
<span class="glyphicon glyphicon-calendar"></span> <time datetime="2013-10-11T23:25:00+08:00" data-updated="true" itemprop="datePublished dateCreated">Oct 11<sup>th</sup>, 2013</time>
| <a href="/blog/2013/10/11/ba-cs50-dot-htian-jia-dao-ku-zhong/#disqus_thread" itemprop="discussionUrl"
data-disqus-identifier="http://freealvin.github.io/blog/2013/10/11/ba-cs50-dot-htian-jia-dao-ku-zhong/">Comments</a>
</p>
<h1 class="entry-title" itemprop="name headline"><a href="/blog/2013/10/11/ba-cs50-dot-htian-jia-dao-ku-zhong/" itemprop="url">把cs50.h添加到库中</a></h1>
</header>
<div class="entry-content clearfix" itemprop="articleBody description"><p> 我最近在看网易公开课CS50,自我感觉非常喜欢David J. Malan的教学方法,非常羡慕和感慨哈佛学生的大学学习环境。也感谢网易为广大中国学生带来的福利。</p>
<p> 以下是自己网上搜素总结的如何模仿搭建CS50中Malan使用的开发环境。</p>
<p> </div>
<footer>
<a class="btn btn-default" href="/blog/2013/10/11/ba-cs50-dot-htian-jia-dao-ku-zhong/">more →</a>
</footer>
</article>
</div>
<ul class="pager">
<li class="previous"><a href="/posts/2">← Older</a></li>
<li><a href="/blog/archives">Blog Archives</a></li>
<li class="next disabled"><a href="#">Newer →</a></li>
</ul>
</div>
<aside class="sidebar col-md-3">
<section class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Recent Posts</h3>
</div>
<div id="recent_posts" class="list-group">
<a class="list-group-item " href="/blog/2015/04/13/javacan-shu-chuan-di/">Java参数传递</a>
<a class="list-group-item " href="/blog/2015/04/11/java-lei-de-finalyin-yong-cheng-yuan-shi-li/">Java 类的final引用成员实例</a>
<a class="list-group-item " href="/blog/2015/04/08/unixhuan-jing-gao-ji-bian-cheng-zhi-jin-cheng-huan-jing/">Unix环境高级编程之进程环境</a>
<a class="list-group-item " href="/blog/2015/04/04/liu-ge-yue-hou/">六个月后</a>
<a class="list-group-item " href="/blog/2013/12/02/cyu-yan-de-suo-jin-he-kong-bai/">C语言的缩进和空白</a>
</div>
</section>
<section>
<h1>Categories</h1>
<ul id="categories">
<li class='category'><a href='/blog/categories/algorithm/'>algorithm (2)</a></li>
<li class='category'><a href='/blog/categories/c/'>c (4)</a></li>
<li class='category'><a href='/blog/categories/c-/'>c++ (7)</a></li>
<li class='category'><a href='/blog/categories/centos/'>centos (3)</a></li>
<li class='category'><a href='/blog/categories/git/'>git (1)</a></li>
<li class='category'><a href='/blog/categories/java/'>java (2)</a></li>
<li class='category'><a href='/blog/categories/linux/'>linux (6)</a></li>
<li class='category'><a href='/blog/categories/octopress/'>octopress (1)</a></li>
<li class='category'><a href='/blog/categories/python/'>python (3)</a></li>
<li class='category'><a href='/blog/categories/ruby/'>ruby (1)</a></li>
<li class='category'><a href='/blog/categories/基础/'>基础 (2)</a></li>
</ul>
</section>
</aside>
</div>
</div>
</div>
</div>
<footer role="contentinfo"><div class="container">
<p class="text-muted credits">
Copyright © 2015 - Alvin<br>
<small>
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>,
<span class="credit">customized with <a href="https://github.com/kAworu/octostrap3">octostrap3</a></span>.
</small>
</p>
</div>
</footer>
<script type="text/javascript">
var disqus_shortname = 'freealvin';
var disqus_script = 'count.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = '//platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
<script src="/assets/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/javascripts/modernizr-2.0.js"></script>
</body>
</html>