diff --git a/README.md b/README.md index 0fe98de7d..f0fba24b5 100644 --- a/README.md +++ b/README.md @@ -353,10 +353,10 @@ average(1, 2, 3); * [`mask`](#mask) * [`palindrome`](#palindrome) * [`pluralize`](#pluralize) +* [`removeNonASCII`](#removenonascii) * [`reverseString`](#reversestring) * [`sortCharactersInString`](#sortcharactersinstring) * [`splitLines`](#splitlines) -* [`stripHTMLtags`](#striphtmltags) * [`toCamelCase`](#tocamelcase) * [`toKebabCase`](#tokebabcase) * [`toSnakeCase`](#tosnakecase) @@ -421,6 +421,15 @@ average(1, 2, 3); +### _Uncategorized_ + +
+View contents + +* [`stripHTMLtags`](#striphtmltags) + +
+ --- ## 🔌 Adapter @@ -6238,6 +6247,28 @@ autoPluralize(2, 'person'); // 'people'
[⬆ Back to top](#table-of-contents) +### removeNonASCII + +Removes non-printable ASCII characters. + +Use a regular expression to remove non-printable ASCII characters. + +```js +const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); +``` + +
+Examples + +```js +removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum' +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### reverseString Reverses a string. @@ -6305,28 +6336,6 @@ splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline',
[⬆ Back to top](#table-of-contents) -### stripHTMLTags - -Removes HTML/XML tags from string. - -Use a regular expression to remove HTML/XML tags from a string. - -```js -const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); -``` - -
-Examples - -```js -stripHTMLTags('

lorem ipsum

'); // 'lorem ipsum' -``` - -
- -
[⬆ Back to top](#table-of-contents) - - ### toCamelCase Converts a string to camelcase. @@ -7585,6 +7594,25 @@ yesNo('Foo', true); // true
[⬆ Back to top](#table-of-contents) +--- + ## _Uncategorized_ + +### stripHTMLTags + +Removes HTML/XML tags from string. + +Use a regular expression to remove HTML/XML tags from a string. + +```js +const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); +``` + +```js +stripHTMLTags('

lorem ipsum

'); // 'lorem ipsum' +``` + +
[⬆ back to top](#table-of-contents) + ## Collaborators diff --git a/docs/index.html b/docs/index.html index 2057fa49f..d23af6397 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -1427,14 +1427,14 @@ Foo.prototype};
 const autoPluralize = pluralize(PLURALS);
 autoPluralize(2, 'person'); // 'people'
+

removeNonASCII

Removes non-printable ASCII characters.

Use a regular expression to remove non-printable ASCII characters.

const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
+
removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum'
 

reverseString

Reverses a string.

Use the spread operator (...) and Array.reverse() to reverse the order of the characters in the string. Combine characters to get a string using String.join('').

const reverseString = str => [...str].reverse().join('');
 
reverseString('foobar'); // 'raboof'
 

sortCharactersInString

Alphabetically sorts the characters in a string.

Use the spread operator (...), Array.sort() and String.localeCompare() to sort the characters in str, recombine using String.join('').

const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join('');
 
sortCharactersInString('cabbage'); // 'aabbceg'
 

splitLines

Splits a multiline string into an array of lines.

Use String.split() and a regular expression to match line breaks and create an array.

const splitLines = str => str.split(/\r?\n/);
 
splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string.' , '']
-

stripHTMLTags

Removes HTML/XML tags from string.

Use a regular expression to remove HTML/XML tags from a string.

const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
-
stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p>'); // 'lorem ipsum'
 

toCamelCase

Converts a string to camelcase.

Break the string into words and combine them capitalizing the first letter of each word, using a regexp.

const toCamelCase = str => {
   let s =
     str &&
@@ -1766,4 +1766,6 @@ Logs: {
 yesNo('yes'); // true
 yesNo('No'); // false
 yesNo('Foo', true); // true
-
\ No newline at end of file +

Uncategorized

stripHTMLTags

Removes HTML/XML tags from string.

Use a regular expression to remove HTML/XML tags from a string.

const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
+
stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p>'); // 'lorem ipsum'
+
\ No newline at end of file diff --git a/tag_database b/tag_database index 2776e888d..4e20c4596 100644 --- a/tag_database +++ b/tag_database @@ -214,7 +214,7 @@ sortedLastIndexBy:array,math,function splitLines:string spreadOver:adapter standardDeviation:math,array -stripHTMLTags:string,utility,regexp +stripHTMLtags:uncategorized sum:math,array sumBy:math,array,function sumPower:math