minor renovations, beautify round 2 (final)

This commit is contained in:
Ilya Kantor 2015-03-12 10:26:02 +03:00
parent fad6615c42
commit 8410ce6421
212 changed files with 1981 additions and 1717 deletions

View file

@ -20,7 +20,7 @@
```js
//+ run
alert( "Мне 12345 лет".match (/\d{5}/) ); // "12345"
alert( "Мне 12345 лет".match(/\d{5}/) ); // "12345"
```
</dd>
@ -29,14 +29,14 @@ alert( "Мне 12345 лет".match (/\d{5}/) ); // "12345"
```js
//+ run
alert( "Мне не 12, а 1234 года".match( /\d{3,5}/ ) ); // "1234"
alert( "Мне не 12, а 1234 года".match(/\d{3,5}/) ); // "1234"
```
Последнее значение можно и не указывать. Тогда выражение <code class="pattern">\d{3,}</code> найдет числа, длиной от трех цифр:
```js
//+ run
alert( "Мне не 12, а 345678 лет".match( /\d{3,5}/ ) ); // "345678"
alert( "Мне не 12, а 345678 лет".match(/\d{3,5}/) ); // "345678"
```
</dd>
</dl>
@ -47,7 +47,7 @@ alert( "Мне не 12, а 345678 лет".match( /\d{3,5}/ ) ); // "345678"
//+ run
var str = "+7(903)-123-45-67";
alert( str.match( /\d{1,}/g ) ); // 7,903,123,45,67
alert( str.match(/\d{1,}/g) ); // 7,903,123,45,67
```
@ -65,7 +65,7 @@ alert( str.match( /\d{1,}/g ) ); // 7,903,123,45,67
//+ run
var str = "+7(903)-123-45-67";
alert( str.match( /\d+/g ) ); // 7,903,123,45,67
alert( str.match(/\d+/g) ); // 7,903,123,45,67
```
</dd>
@ -80,7 +80,7 @@ alert( str.match( /\d+/g ) ); // 7,903,123,45,67
//+ run
var str = "Можно писать color или colour (британский вариант)";
alert( str.match( /colou?r/g ) ); // color, colour
alert( str.match(/colou?r/g) ); // color, colour
```
</dd>
@ -91,14 +91,14 @@ alert( str.match( /colou?r/g ) ); // color, colour
```js
//+ run
alert( "100 10 1".match( /\d0*/g ) ); // 100, 10, 1
alert( "100 10 1".match(/\d0*/g) ); // 100, 10, 1
```
Сравните это с `'+'` (один или более):
```js
//+ run
alert( "100 10 1".match( /\d0+/g ) ); // 100, 10
alert( "100 10 1".match(/\d0+/g) ); // 100, 10
```
</dd>
@ -115,7 +115,7 @@ alert( "100 10 1".match( /\d0+/g ) ); // 100, 10
В действии:
```js
//+ run
alert( "0 1 12.345 7890".match( /\d+\.\d+/g ) ); // 123.45
alert( "0 1 12.345 7890".match(/\d+\.\d+/g) ); // 123.45
```
</dd>
@ -124,7 +124,7 @@ alert( "0 1 12.345 7890".match( /\d+\.\d+/g ) ); // 123.45
```js
//+ run
alert( "<BODY> ... </BODY>".match ( /<[a-z]+>/gi ) ); // <BODY>
alert( "<BODY> ... </BODY>".match(/<[a-z]+>/gi) ); // <BODY>
```
Это регулярное выражение ищет символ <code class="pattern">'&lt;'</code>, за которым идут одна или более букв английского алфавита, и затем <code class="pattern">'&gt;'</code>.
@ -135,7 +135,7 @@ alert( "<BODY> ... </BODY>".match ( /<[a-z]+>/gi ) ); // <BODY>
```js
//+ run
alert( "<h1>Привет!</h1>".match( /<[a-z][a-z0-9]*>/gi ) ); // <h1>
alert( "<h1>Привет!</h1>".match(/<[a-z][a-z0-9]*>/gi) ); // <h1>
```
</dd>
@ -144,7 +144,7 @@ alert( "<h1>Привет!</h1>".match( /<[a-z][a-z0-9]*>/gi ) ); // <h1>
```js
//+ run
alert( "<h1>Привет!</h1>".match( /<\/?[a-z][a-z0-9]*>/gi ) ); // <h1>, </h1>
alert( "<h1>Привет!</h1>".match(/<\/?[a-z][a-z0-9]*>/gi) ); // <h1>, </h1>
```
</dd>