diff --git a/README.md b/README.md index 21036c904..6fe83767a 100644 --- a/README.md +++ b/README.md @@ -358,6 +358,7 @@ average(1, 2, 3); * [`reverseString`](#reversestring) * [`sortCharactersInString`](#sortcharactersinstring) * [`splitLines`](#splitlines) +* [`stripHTMLTags`](#striphtmltags) * [`toCamelCase`](#tocamelcase) * [`toKebabCase`](#tokebabcase) * [`toSnakeCase`](#tosnakecase) @@ -422,15 +423,6 @@ average(1, 2, 3); -### _Uncategorized_ - -
-View contents - -* [`stripHTMLTags`](#striphtmltags) - -
- --- ## 🔌 Adapter @@ -6372,6 +6364,28 @@ 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. @@ -7630,25 +7644,6 @@ 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 d6289dbdd..8a3a2b580 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);
@@ -1450,6 +1450,8 @@ Foo.prototypeShow examples
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 &&
@@ -1781,6 +1783,4 @@ Logs: {
 yesNo('yes'); // true
 yesNo('No'); // false
 yesNo('Foo', true); // true
-

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 +
\ No newline at end of file