From 3ab093b7b3b9d9b16018f02dc7700f2c7349291a Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Thu, 5 Mar 2026 16:08:05 +0530 Subject: [PATCH] fix(curriculum): change some example codes to non-interactive (#66161) --- .../6723cdfa4ae237bf6b7e32eb.md | 27 ++++++++++++------- .../6723d3cfdd0717d3f1bf27e3.md | 25 ++++++++++------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/curriculum/challenges/english/blocks/review-javascript-regular-expressions/6723cdfa4ae237bf6b7e32eb.md b/curriculum/challenges/english/blocks/review-javascript-regular-expressions/6723cdfa4ae237bf6b7e32eb.md index 2e269b18397..b4dd5e4ac38 100644 --- a/curriculum/challenges/english/blocks/review-javascript-regular-expressions/6723cdfa4ae237bf6b7e32eb.md +++ b/curriculum/challenges/english/blocks/review-javascript-regular-expressions/6723cdfa4ae237bf6b7e32eb.md @@ -29,16 +29,12 @@ console.log(test); // false - **`match()` Method**: This method accepts a regular expression, although you can also pass a string which will be constructed into a regular expression. The `match` method returns the match array for the string. -:::interactive_editor - ```js const regex = /freeCodeCamp/; const match = "freeCodeCamp".match(regex); -console.log(match); // ["freeCodeCamp"] +console.log(match); // ['freeCodeCamp', index: 0, input: 'freeCodeCamp', groups: undefined] ``` -::: - - **`replace()` Method**: This method accepts two arguments: the regular expression to match (or a string), and the string to replace the match with (or a function to run against each match). :::interactive_editor @@ -140,15 +136,26 @@ console.log(end.test(str)); // true - **`d` Flag**: This flag expands the information you get in a match object. -:::interactive_editor - ```js const regex = /freecodecamp/di; const string = "we love freecodecamp isn't freecodecamp great?"; console.log(string.match(regex)); ``` -::: +And the result is: + +```js +// [ +// 'freecodecamp', +// index: 8, +// input: "we love freecodecamp isn't freecodecamp great?", +// groups: undefined, +// indices: [ +// 0: [8, 20], +// groups: undefined +// ] +// ] +``` - **`u` Flag**: This expands the functionality of a regular expression to allow it to match special unicode characters. The `u` flag gives you access to special classes like the `Extended_Pictographic` to match most emoji. There is also a `v` flag, which further expands the functionality of the unicode matching. - **`y` Flag**: The sticky modifier behaves very similarly to the global modifier, but with a few exceptions. The biggest one is that a global regular expression will start from lastIndex and search the entire remainder of the string for another match, but a sticky regular expression will return null and reset the lastIndex to 0 if there is not immediately a match at the previous lastIndex. @@ -260,8 +267,8 @@ console.log("freecoooooooodecamp".replace(regex, "paid$1world")); ```js const regex = /(hello) \1/i; -console.log(regex.test("hello hello")); // true -console.log(regex.test("hello world")); // false +console.log(regex.test("hello hello")); // true +console.log(regex.test("hello world")); // false ``` ::: diff --git a/curriculum/challenges/english/blocks/review-javascript/6723d3cfdd0717d3f1bf27e3.md b/curriculum/challenges/english/blocks/review-javascript/6723d3cfdd0717d3f1bf27e3.md index fa749e65766..89810a9543f 100644 --- a/curriculum/challenges/english/blocks/review-javascript/6723d3cfdd0717d3f1bf27e3.md +++ b/curriculum/challenges/english/blocks/review-javascript/6723d3cfdd0717d3f1bf27e3.md @@ -2698,16 +2698,12 @@ console.log(test); // false - **`match()` Method**: This method accepts a regular expression, although you can also pass a string which will be constructed into a regular expression. The `match` method returns the match array for the string. -:::interactive_editor - ```js const regex = /freeCodeCamp/; const match = "freeCodeCamp".match(regex); -console.log(match); // ["freeCodeCamp"] +console.log(match); // ['freeCodeCamp', index: 0, input: 'freeCodeCamp', groups: undefined] ``` -::: - - **`replace()` Method**: This method accepts two arguments: the regular expression to match (or a string), and the string to replace the match with (or a function to run against each match). :::interactive_editor @@ -2809,15 +2805,26 @@ console.log(end.test(str)); // true - **`d` Flag**: This flag expands the information you get in a match object. -:::interactive_editor - -```ts +```js const regex = /freecodecamp/di; const string = "we love freecodecamp isn't freecodecamp great?"; console.log(string.match(regex)); ``` -::: +And the result is: + +```js +// [ +// 'freecodecamp', +// index: 8, +// input: "we love freecodecamp isn't freecodecamp great?", +// groups: undefined, +// indices: [ +// 0: [8, 20], +// groups: undefined +// ] +// ] +``` - **`u` Flag**: This expands the functionality of a regular expression to allow it to match special unicode characters. The `u` flag gives you access to special classes like the `Extended_Pictographic` to match most emoji. There is also a `v` flag, which further expands the functionality of the unicode matching. - **`y` Flag**: The sticky modifier behaves very similarly to the global modifier, but with a few exceptions. The biggest one is that a global regular expression will start from lastIndex and search the entire remainder of the string for another match, but a sticky regular expression will return null and reset the lastIndex to 0 if there is not immediately a match at the previous lastIndex.