-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1067 lines (520 loc) · 31.4 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
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html class="theme-next pisces use-motion">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />
<meta name="keywords" content="Hexo, NexT" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.2" />
<meta name="description" content="我们不是在学习,就是走在学习的路上。记录下一路的足迹,留着茶余饭后回味。">
<meta property="og:type" content="website">
<meta property="og:title" content="Summy's Blog">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Summy's Blog">
<meta property="og:description" content="我们不是在学习,就是走在学习的路上。记录下一路的足迹,留着茶余饭后回味。">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Summy's Blog">
<meta name="twitter:description" content="我们不是在学习,就是走在学习的路上。记录下一路的足迹,留着茶余饭后回味。">
<script type="text/javascript" id="hexo.configuration">
var NexT = window.NexT || {};
var CONFIG = {
scheme: 'Pisces',
sidebar: {"position":"right","display":"post"},
fancybox: true,
motion: true,
duoshuo: {
userId: '0',
author: '博主'
}
};
</script>
<link rel="canonical" href="http://yoursite.com/"/>
<title> Summy's Blog </title>
</head>
<body itemscope itemtype="//schema.org/WebPage" lang="zh-Hans">
<div class="container one-collumn sidebar-position-right
page-home
">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
<div class="header-inner"><div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Summy's Blog</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle"></p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
首页
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />
分类
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
归档
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
标签
</a>
</li>
<li class="menu-item menu-item-schedule">
<a href="/schedule" rel="section">
<i class="menu-item-icon fa fa-fw fa-calendar"></i> <br />
日程
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal " itemscope itemtype="//schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/08/23/CSS中的margin属性/" itemprop="url">
CSS中的margin属性
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2017-08-23T19:43:33+08:00" content="2017-08-23">
2017-08-23
</time>
</span>
<span class="post-comments-count">
|
<a href="/2017/08/23/CSS中的margin属性/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2017/08/23/CSS中的margin属性/" itemprop="commentsCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="CSS中的margin属性"><a href="#CSS中的margin属性" class="headerlink" title="CSS中的margin属性"></a>CSS中的margin属性</h1><blockquote>
<p>作为一个(wei)前端工作者,一定一定要多多看看基础,因为这可能决定了你是不是会花几个小时甚至几天去改一个基础到无法再基础的bug,最近工作内容以重构为主,悲催的发现自己这实现速度简直是逆了天的慢,默默回头复习(xue xi)一下基础知识。</p>
</blockquote>
<p>CSS是页面重构中不可或缺的部分,其中最重要的三个概念就是浮动,定位和盒模型,以下则是来了解CSS中盒模型中的一个重要属性:margin属性。</p>
<h2 id="1、CSS盒模型"><a href="#1、CSS盒模型" class="headerlink" title="1、CSS盒模型"></a>1、CSS盒模型</h2><p>CSS中有两种盒模型:<strong>IE盒模型</strong>和<strong>标准盒模型</strong>,IE6及以下版本浏览器在混合模式下会使用IE盒模型,普遍浏览器则是使用标准盒模型。这两者的区别如下(PS:这两张图是顺来的,一直很喜欢这两张图,感谢前人提供的便捷,hhh~):<br><img src="http://i.imgur.com/H52GDhf.jpg" alt=""><br><img src="http://i.imgur.com/OmBaAkG.jpg" alt=""></p>
<p>这两种盒子模型区别就在于CSS中width属性的范围,标准盒子模型,width设置的是盒子内内容的宽度;IE盒子模型的width属性范围则是盒子内内容+内边距+外边框的宽度。</p>
<h2 id="2、可视区域"><a href="#2、可视区域" class="headerlink" title="2、可视区域"></a>2、可视区域</h2><p>这里我们要引入一个“可视区域”的概念,这里所指的“可视区域”是指盒子在页面中能让我们肉眼看得见的(可以理解为background-color中能影响到的区域)。</p>
<p>margin范围为透明的,虽然我们无法直接在视觉上将其辨别出来,但它确实真实存在且在文档中有相应的占据尺寸。我们平时使用margin值设置上下左右就是通过其来设置盒子的可用模型。</p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="//schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/06/13/about-defineProperty/" itemprop="url">
Object.defineProperty
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2017-06-13T19:27:43+08:00" content="2017-06-13">
2017-06-13
</time>
</span>
<span class="post-comments-count">
|
<a href="/2017/06/13/about-defineProperty/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2017/06/13/about-defineProperty/" itemprop="commentsCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Object-defineProperty"><a href="#Object-defineProperty" class="headerlink" title="Object.defineProperty"></a>Object.defineProperty</h1><blockquote>
<p>前奏又一波:最近频繁遇到Object.defineProperty这个方法,百度一下,这是ES5的一个方法,一般用于给对象添加新属性或者修改原有属性,Vue.js和avalon.js框架都使用这个方法实现数据双向绑定,所以学习一下这个方法。</p>
</blockquote>
<h2 id="定义"><a href="#定义" class="headerlink" title="定义"></a>定义</h2><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty" target="_blank" rel="external">MDN</a>上的定义是这样子的。</p>
<pre><code>The Object.defineProperty() method defines a new property directly on an
object, or modifies an existing property on an object, and returns the
object.
</code></pre><p>翻译过来就是用于直接为指定的对象定义属性,或者是修改原有的属性的值,再以该对象作为返回值。<br><br>具体方法如下:<br></p>
<pre><code>object.defineproperty(obj, prop, descriptor)
</code></pre><p>其中,</p>
<ul>
<li>obj, 表示要添加属性或修改属性的对象</li>
<li>prop,表示添加或者修改的属性名称</li>
<li>descriptor,对于属性的一些描述,也就是说定义属性的一些内在属性,包括是否可枚举,能否修改等等。</li>
</ul>
<p><strong>用法:</strong></p>
<pre><code>var obj = {}
Object.defineProperty(obj, 'tell', {
value : 'I am telling'
});
Object.defineProperty(obj, 'sing', {
value : 'I am singing',
enumerable : true
});
Object.defineProperty(obj, 'dance', {
value : 'I am dancing'
});
for(key in obj) {
console.log(key)
}
console.log(Object.keys(obj));
</code></pre><p><strong>运行结果:</strong></p>
<pre><code>sing //console.log(key)的运行结果
['sing'] //console.log(Object.keys(obj))
</code></pre><p>这样一个简单的用法,看起来似乎和object[]和object.XXX的用法并没很大的区别,笔者也有同感,在各种场景看到Object.defineProperty方法时,一直在想有什么绝命杀要我们多打那么个字符呢,我可是一个信奉能躺着绝不坐着的,能省绝不啰嗦的人,当然得好好扒扒原因。</p>
<p>首先,从MSD的定义我们可以看到,这个方法重点应该在弟三个参数descriptor上,在官方发布的文档上,这个参数需要传入一个对象:</p>
<pre><code>{
configurable //默认值为false
enumable //默认值为 false,当为false的时候, (for...in loop or Object.keys方法)无法遍历属性
writable //默认值为false,这个属性不能与get/set同时使用
value //默认值为null
get //默认值为undefined
set //默认值为undefined
}
</code></pre><p>经过多番查找,以及尝试,发掘Object.defineProperty方法的几个<strong>优势</strong>如下:</p>
<ol>
<li><p>能够保护一个变量,使其具有私有变量的安全性。当定义一个与函数内部变量同名的函数的属性,外部环境将无法访问到函数内的这个变量。如下代码说明:</p>
<pre><code>function Animal () {
var name = "";
Object.defineProperty(this, 'name', {
get : function() {
return name;
},
set : function(value) {
name = value;
}
});
}
var dog = new Animal();
console.log(dog.name);
dog.name = 'dog'; //设置的是属性name的值而不是变量name的值
console.log(dog.name);
</code></pre></li>
<li><p>能够设置默认不可更改变量。writable属性能够设置让外界无法更改内部变量的值。这个的好处就是使属性私有化,保护重要的属性不被修改。</p>
</li>
<li>getter和setter访问器。Object.defineProperty将属性进行包装。这也是前端用于实现数据绑定的重要原理。Vue.js的数据绑定就是基于此实现的。</li>
<li><p>在原型链屏蔽属性。我们了解在原型链上,相同的属性可能发生属性屏蔽,具体关系如下:</p>
<pre><code>var anotherObject = {
name: 'anotherObject',
a: 1
}
myObject = Object.create(anotherObject); //这里将myObject.prototype指向anotherObject对象
myObject.b = 2;
console.log(myObject.b); //2
console.log(myObject.a); //1
myObject.a = 11; //这里发生了属性屏蔽,myObject添加了属于自己的a,便不会再向上寻找anotherObject获取a的值
console.log(myObject.a); //11
</code></pre></li>
</ol>
<p> 然而并非是任何的添加相同的属性名都会发生属性屏蔽的现象,可以说发生属性屏蔽的场景是有限制。 上一个例子中,myObject.a = 11赋值操作能够顺利添加到myObject上,是由于在[[prototype]]链上(这里指anthorObject)的a属性只是一个普通数据访问属性。下面的这两种情况,将不会发生属性屏蔽现象。</p>
<p> 场景: 为myObject添加c属性</p>
<ul>
<li>如果[[prototype]]链上层存在c属性,但其被标记为只读(writeable:true),那么myObject无法为自身添加c属性或者是修改原有的c属性。</li>
<li><p>如果[[prototype]]链上层存在c属性,且其为一个setter,那么myObject.c将会调用这个setter,不会在myObject自身添加或修改c属性。</p>
<p>上面两种情况的解决办法便是使用<strong>Object.defineProperty()</strong></p>
</li>
</ul>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="//schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/11/04/my-new-post/" itemprop="url">
正则表达式里的小九九
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-11-04T15:42:27+08:00" content="2016-11-04">
2016-11-04
</time>
</span>
<span class="post-comments-count">
|
<a href="/2016/11/04/my-new-post/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2016/11/04/my-new-post/" itemprop="commentsCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>#正则表达式里的小九九#</p>
<blockquote>
<p>前奏:从上大学的时候接触的第一门编程语言,就学到了正则表达式,然而至今,每次看到正则表达式匹配都像在看达芬奇密码一样,一头雾水,搬代码时候需要实现什么语句匹配时,内心真的是内牛满面。</p>
</blockquote>
<p><strong>接着唠</strong>:google或者百度一下,发现网上正则表达式教程比比皆是,记录得很详细,但是每次看完,还是一脸懵逼,写得虽然详细,但是记不住啊,我特别不擅长于记忆一些零零碎碎的知识点,故,将学到的正则表达式语法归纳总结一下,也算是检验一下自己的学习成果,增强记忆。</p>
<h2 id="声明"><a href="#声明" class="headerlink" title="声明"></a>声明</h2><ul>
<li><p>正则表达式字面量 (推荐)</p>
<p> var reg = /exp/ //在两个斜杠之间书写正则表达式字符</p>
</li>
</ul>
<ul>
<li><p>RegExp对象声明</p>
<p> var reg = new RegExp(exp,signal)</p>
</li>
</ul>
<p>这两种方式都可以声明一个正则表达式,但是比较推荐字面量(所谓字面量就是字面上就能看出是表达式的一种形式)声明,这样可以兼容更多的浏览器版本,如果你用过ie8及以下版本,你就会发现使用RegExp声明变量会出现一些问题。</p>
<h2 id="标识"><a href="#标识" class="headerlink" title="标识"></a>标识</h2><pre><code>g--global 全局匹配
i--ignoreCase 忽略大小写
m--multiline 多行匹配
</code></pre><h2 id="元字符"><a href="#元字符" class="headerlink" title="元字符"></a>元字符</h2><pre><code>^ 匹配初始位置,表示正则表达式的开始
$ 匹配结束位置,表示正则表达式的结束
. 匹配除了换行符之外的所以字符
\w 匹配数字,字母,下划线,汉字等
\d 匹配数字
\s 匹配任意空白字符
\b 匹配单词开头或者结束
</code></pre><h2 id="反义字符"><a href="#反义字符" class="headerlink" title="反义字符"></a>反义字符</h2><p>反义字符是基于元字符的基础上的,在正则表达式中,对于大小写是敏感的,大小写字符甚至代表着截然不同的两种情况。</p>
<pre><code>\W 匹配任意不是数字,字母,下划线,汉字等的字符
\D 匹配任意不是数字的字符
\S 匹配任意不是空白字符的字符
\B 匹配不是单词开头或者结束
</code></pre><h2 id="求反"><a href="#求反" class="headerlink" title="求反"></a>求反</h2><p>[^exp]这种情况下会匹配非exp的字符。</p>
<h2 id="量词"><a href="#量词" class="headerlink" title="量词"></a>量词</h2><p>上面的元字符与反义字符只能匹配单一的字符,例如,\d只能匹配1,无法匹配123,要想达到重复的效果,需要使用量词来控制匹配字符的数量。</p>
<pre><code>* 匹配 >=0次
+ 匹配 >=1次
? 匹配 <=1次
{n} 匹配 =n次
{n,m} 匹配 >=n且<=m次
{n,} 匹配 >=n次
</code></pre><h2 id="贪婪模式与懒惰模式"><a href="#贪婪模式与懒惰模式" class="headerlink" title="贪婪模式与懒惰模式"></a>贪婪模式与懒惰模式</h2><p>我们平时的正则表达式都是以默认为贪婪模式的,通俗点讲就是尽量多的匹配</p>
<h2 id="范围类"><a href="#范围类" class="headerlink" title="范围类"></a>范围类</h2><p>正则表达式采用[](中括号)来表示范围,如[a-z]表示匹配小写字母a~z中任何一个字符</p>
<h2 id="分组"><a href="#分组" class="headerlink" title="分组"></a>分组</h2><p>正则表达式采用()(小括号)来表示分组情况,()之中的被划分为一组,分组会出现两种情况:<strong>非捕获分组</strong>和<strong>捕获分组</strong></p>
<ul>
<li><p>非捕获分组 (?:exp)</p>
<p> 非捕获分组只能匹配文本,不会复制所匹配的文本存储到数组或其他地方,也不会将匹配文本放置到内置变量$1、$2..等中,即只能用于判断,无法用于其他操作</p>
</li>
</ul>
<ul>
<li><p>捕获分组 (exp)与(?<name>exp)</name></p>
<p> (exp)将捕获后的文本复制到内部变量$1、$2…</p>
<p> (?<name>exp)将捕获后的文本复制到自定义命名的组名name中</name></p>
<p> 捕获组可以提取匹配到得到文本进行后面的操作,这对于提取例如url后面的参数非常有用</p>
</li>
</ul>
<h2 id="操作方法"><a href="#操作方法" class="headerlink" title="操作方法"></a>操作方法</h2><ul>
<li><p>test()</p>
<p> 属于RegExp对象的一个方法,即regexp.test(string)</p>
<p> 返回值为:boolean类型的值,若匹配到文本,则返回true,反之,返回false</p>
</li>
</ul>
<pre><code>- 只是起到检测作用,是正则表达式中最简单也是匹配速度最快的方法,这个方法不能是用g
- (全局)标识
- 如果regexp匹配到string后则会立即返回,且lastIndex值为匹配文本后的第一个字符的下标
eg: var reg = /^a/; reg.test('dgag') 返回true,teg.lastIndex = 3
</code></pre><ul>
<li><p>match()</p>
<p> match()按顺序匹配,若匹配到文本,则会返回,不会接下去匹配后面的字符</p>
</li>
<li><p>search()</p>
</li>
<li><p>exec()</p>
<p> 属于RegExp对象的一个方法,即regexp.exec(string)</p>
<p> 返回值:若匹配到文本,则返回数组,反之,则返回一个null值</p>
<pre><code>- 主要是根据捕获分组来存储每组匹配的文本,数组第一项存储的是整个正则表达式匹配的文本,第二项开始分别对应捕获组1、捕获组2...的匹配文本
- 如果使用了g标识,则每次匹配后lastIndex属性不会重置到0,而是将其设置为该匹配后第一个字符的位置
- ^因子仅匹配lastIndex为0的情况
</code></pre></li>
</ul>
<h2 id="拓展学习"><a href="#拓展学习" class="headerlink" title="拓展学习"></a>拓展学习</h2><p><a href="https://regexper.com" target="_blank" rel="external">正则表达式在线学习工具</a></p>
<p><a href="http://tool.chinaz.com/regex/" target="_blank" rel="external">正则表达式在线测试工具</a></p>
<p>JavaScript语言精粹第七章</p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="//schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/11/04/hello-world/" itemprop="url">
Hello World
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-11-04T13:30:04+08:00" content="2016-11-04">
2016-11-04
</time>
</span>
<span class="post-comments-count">
|
<a href="/2016/11/04/hello-world/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2016/11/04/hello-world/" itemprop="commentsCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>Welcome to <a href="https://hexo.io/" target="_blank" rel="external">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="external">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="external">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="external">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo new <span class="string">"My New Post"</span></div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="external">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo server</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="external">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo generate</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="external">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo deploy</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="external">Deployment</a></p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</section>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<section class="site-overview sidebar-panel sidebar-panel-active ">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
<img class="site-author-image" itemprop="image"
src="/image/logo.jpg"
alt="Summy" />
<p class="site-author-name" itemprop="name">Summy</p>
<p class="site-description motion-element" itemprop="description">我们不是在学习,就是走在学习的路上。记录下一路的足迹,留着茶余饭后回味。</p>
</div>
<nav class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives">
<span class="site-state-item-count">4</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
</nav>
<div class="links-of-author motion-element">
</div>
</section>
</div>
</aside>
</div>
</main>
<footer id="footer" class="footer">
<div class="footer-inner">
<div class="copyright" >
©
<span itemprop="copyrightYear">2017</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Summy</span>
</div>
<div class="powered-by">
由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>
<div class="theme-info">
主题 -
<a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
NexT.Pisces
</a>
</div>
</div>
</footer>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
</div>
</div>
<script type="text/javascript">
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
</script>
<script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
<script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
<script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>