From 38b67851fb61ddfaf1270e3f1751f5c0a1404027 Mon Sep 17 00:00:00 2001 From: Behnam Mohammadi Date: Thu, 31 Dec 2020 00:42:11 +0330 Subject: [PATCH 1/3] fix output --- 9-regular-expressions/17-regexp-methods/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/9-regular-expressions/17-regexp-methods/article.md b/9-regular-expressions/17-regexp-methods/article.md index ef578020d6..deabca0485 100644 --- a/9-regular-expressions/17-regexp-methods/article.md +++ b/9-regular-expressions/17-regexp-methods/article.md @@ -95,13 +95,13 @@ Splits the string using the regexp (or a substring) as a delimiter. We can use `split` with strings, like this: ```js run -alert('12-34-56'.split('-')) // array of [12, 34, 56] +alert('12-34-56'.split('-')) // array of ['12', '34', '56'] ``` But we can split by a regular expression, the same way: ```js run -alert('12, 34, 56'.split(/,\s*/)) // array of [12, 34, 56] +alert('12, 34, 56'.split(/,\s*/)) // array of ['12', '34', '56'] ``` ## str.search(regexp) From 4d476901e3cd40ff82c6e8c5bd37455e6a23850c Mon Sep 17 00:00:00 2001 From: Behnam Mohammadi Date: Thu, 31 Dec 2020 00:43:42 +0330 Subject: [PATCH 2/3] add a sample for limit argument in split --- 9-regular-expressions/17-regexp-methods/article.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/9-regular-expressions/17-regexp-methods/article.md b/9-regular-expressions/17-regexp-methods/article.md index deabca0485..6e7185ed45 100644 --- a/9-regular-expressions/17-regexp-methods/article.md +++ b/9-regular-expressions/17-regexp-methods/article.md @@ -104,6 +104,12 @@ But we can split by a regular expression, the same way: alert('12, 34, 56'.split(/,\s*/)) // array of ['12', '34', '56'] ``` +Also we can use `limit` for limit output, like this: + +```js run +alert('12-34-56'.split('-', 2)) // array of ['12', '34'] +``` + ## str.search(regexp) The method `str.search(regexp)` returns the position of the first match or `-1` if none found: From a9230f749cc4b14bb1c7b70dc76b66c6ffec15cf Mon Sep 17 00:00:00 2001 From: Behnam Mohammadi Date: Thu, 31 Dec 2020 00:58:42 +0330 Subject: [PATCH 3/3] fix typo --- 9-regular-expressions/17-regexp-methods/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/9-regular-expressions/17-regexp-methods/article.md b/9-regular-expressions/17-regexp-methods/article.md index 6e7185ed45..b6671d6627 100644 --- a/9-regular-expressions/17-regexp-methods/article.md +++ b/9-regular-expressions/17-regexp-methods/article.md @@ -104,7 +104,7 @@ But we can split by a regular expression, the same way: alert('12, 34, 56'.split(/,\s*/)) // array of ['12', '34', '56'] ``` -Also we can use `limit` for limit output, like this: +Also we can use `limit` to limit output, like this: ```js run alert('12-34-56'.split('-', 2)) // array of ['12', '34']