README.md (2183B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # UTF-16 Unpaired Surrogate 22 23 > [Regular expression][mdn-regexp] to match an unpaired [UTF-16][utf-16] surrogate. 24 25 <section class="usage"> 26 27 ## Usage 28 29 <!-- eslint-disable id-length --> 30 31 ```javascript 32 var reUtf16UnpairedSurrogate = require( '@stdlib/regexp/utf16-unpaired-surrogate' ); 33 ``` 34 35 #### reUtf16UnpairedSurrogate() 36 37 Returns a [regular expression][mdn-regexp] to match an unpaired [UTF-16][utf-16] surrogate. 38 39 <!-- eslint-disable id-length --> 40 41 ```javascript 42 var RE_UTF16_UNPAIRED_SURROGATE = reUtf16UnpairedSurrogate(); 43 44 var bool = RE_UTF16_UNPAIRED_SURROGATE.test( 'abc\uD800def' ); 45 // returns true 46 ``` 47 48 #### reUtf16UnpairedSurrogate.REGEXP 49 50 [Regular expression][mdn-regexp] to match an unpaired [UTF-16][utf-16] surrogate. 51 52 ```javascript 53 var bool = reUtf16UnpairedSurrogate.REGEXP.test( 'abc\uD800def' ); 54 // returns true 55 ``` 56 57 </section> 58 59 <!-- /.usage --> 60 61 <section class="examples"> 62 63 ## Examples 64 65 <!-- eslint-disable id-length --> 66 67 <!-- eslint no-undef: "error" --> 68 69 ```javascript 70 var reUtf16UnpairedSurrogate = require( '@stdlib/regexp/utf16-unpaired-surrogate' ); 71 72 var RE_UTF16_UNPAIRED_SURROGATE = reUtf16UnpairedSurrogate(); 73 74 var bool = RE_UTF16_UNPAIRED_SURROGATE.test( '\uD800' ); 75 // returns true 76 77 bool = RE_UTF16_UNPAIRED_SURROGATE.test( '\uDC00' ); 78 // returns true 79 80 bool = RE_UTF16_UNPAIRED_SURROGATE.test( 'abc' ); 81 // returns false 82 ``` 83 84 </section> 85 86 <!-- /.examples --> 87 88 <section class="links"> 89 90 [mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions 91 92 [utf-16]: https://en.wikipedia.org/wiki/UTF-16 93 94 </section> 95 96 <!-- /.links -->