README.md (3628B)
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 # Remove Punctuation 22 23 > Remove punctuation characters from a string. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var removePunctuation = require( '@stdlib/string/remove-punctuation' ); 37 ``` 38 39 #### removePunctuation( str ) 40 41 Removes punctuation characters from a `string`. 42 43 ```javascript 44 var str = removePunctuation( 'Sun Tzu said: "A leader leads by example not by force."' ); 45 // returns 'Sun Tzu said A leader leads by example not by force' 46 ``` 47 48 The function removes the following characters: 49 50 | description | value | | 51 | :--------------: | :-----: | --- | 52 | Apostrophe | `` ` `` | | 53 | Braces | `{ }` | | 54 | Brackets | `[ ]` | | 55 | Colon | `:` | | 56 | Comma | `,` | | 57 | Exclamation Mark | `!` | | 58 | Fraction Slash | `/` | | 59 | Guillemets | `< >` | | 60 | Parentheses | `( )` | | 61 | Period | `.` | | 62 | Semicolon | `;` | | 63 | Tilde | `~` | | 64 | Vertical Bar | \` | \` | 65 | Question Mark | `?` | | 66 | Quotation Marks | `' "` | | 67 68 </section> 69 70 <!-- /.usage --> 71 72 <section class="examples"> 73 74 ## Examples 75 76 <!-- eslint no-undef: "error" --> 77 78 ```javascript 79 var removePunctuation = require( '@stdlib/string/remove-punctuation' ); 80 81 var str; 82 var out; 83 84 str = 'Double, double, toil and trouble; Fire burn, and cauldron bubble!'; 85 out = removePunctuation( str ); 86 // returns 'Double double toil and trouble Fire burn and cauldron bubble' 87 88 str = 'This module removes these characters: `{}[]:,!/<>().;~|?\'"'; 89 out = removePunctuation( str ); 90 // returns 'This module removes these characters ' 91 92 str = 'We have to hold the border – at all cost'; 93 out = removePunctuation( str ); 94 // returns 'We have to hold the border at all cost' 95 96 str = 'This a sentence without punctuation'; 97 out = removePunctuation( str ); 98 // returns 'This a sentence without punctuation' 99 ``` 100 101 </section> 102 103 <!-- /.examples --> 104 105 * * * 106 107 <section class="cli"> 108 109 ## CLI 110 111 <section class="usage"> 112 113 ### Usage 114 115 ```text 116 Usage: remove-punctuation [options] [<string>] 117 118 Options: 119 120 -h, --help Print this message. 121 -V, --version Print the package version. 122 ``` 123 124 </section> 125 126 <!-- /.usage --> 127 128 <section class="examples"> 129 130 ### Examples 131 132 ```bash 133 $ remove-punctuation 'beep! beep!!!' 134 beep beep 135 ``` 136 137 To use as a [standard stream][standard-streams], 138 139 ```bash 140 $ echo -n 'beep! beep!!!' | remove-punctuation 141 beep beep 142 ``` 143 144 </section> 145 146 <!-- /.examples --> 147 148 </section> 149 150 <!-- /.cli --> 151 152 <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> 153 154 <section class="related"> 155 156 </section> 157 158 <!-- /.related --> 159 160 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 161 162 <section class="links"> 163 164 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams 165 166 </section> 167 168 <!-- /.links -->