Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Conversation

@EddieOne
Copy link

Otherwise, it's easy to miss this use case. Also, shows the single operation limit in contrast to using regex.

@welcome
Copy link

welcome bot commented Feb 21, 2019

💖 Thanks for opening this pull request! 💖
Here is a list of things that will help get it across the finish line:

  • If this is a new or updated CSS interactive example, please ensure that you followed the CSS styleguide - If this is a new or updated JavaScript interactive example, please ensure that you followed the JavaScript styleguide - If your changes affects any of the steps in our contribution docs, please also make the relevant changes there.

@wbamberg
Copy link
Contributor

@EddieOne , thanks ! I like this example (also that it shows the original string is not modified) but the convention is to have a separate // expected output" line for each console.log, so this should be:

var p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';

var regex = /dog/gi;

console.log(p.replace(regex, 'ferret'));
// expected output: "The quick brown fox jumps over the lazy ferret. If the ferret reacted, was it really lazy?"

console.log(p.replace('dog', 'monkey'));
// expected output: "The quick brown fox jumps over the lazy monkey. If the dog reacted, was it really lazy?"

Copy link
Contributor

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you @EddieOne !

@wbamberg wbamberg merged commit 75b4d3e into mdn:master Feb 22, 2019
@welcome
Copy link

welcome bot commented Feb 22, 2019

Congrats on merging your first pull request! 🎉🎉🎉

@EddieOne
Copy link
Author

Cool, thanks!

@EddieOne EddieOne deleted the patch-1 branch February 22, 2019 05:14
wbamberg pushed a commit to dehuszar/interactive-examples that referenced this pull request Feb 22, 2019
* upstream/master: (36 commits)
  Add example of string replace without regex (mdn#1321)
  Revert "added anywhere value to overflow-wrap property" (mdn#1311)
  chore(deps): update dependency all-contributors-cli to v6 (mdn#1313)
  chore(deps): update dependency prettier to v1.16.4 (mdn#1304)
  chore(deps): update dependency ajv to v6.8.1 (mdn#1306)
  chore(deps): update dependency eslint to v5.13.0 (mdn#1305)
  chore(deps): update dependency all-contributors-cli to v5.11.0 (mdn#1302)
  highlight gotchas of array sort (mdn#1308)
  Small Update Join Docs -- Add quotes to show output as a string (mdn#1307)
  Add more Intl.RelativeTimeFormat examples (mdn#1300)
  Add example for globalThis (mdn#1299)
  Add travisbuddy to Travis config (mdn#1301)
  chore(deps): update dependency prettier to v1.16.1 (mdn#1297)
  chore(deps): update dependency mdn-bob to v1.1.23 (mdn#1296)
  chore(deps): update dependency stylelint to v9.10.1 (mdn#1291)
  chore(deps): update dependency eslint to v5.12.1 (mdn#1295)
  chore(deps): update dependency all-contributors-cli to v5.10.2 (mdn#1288)
  [Snyk] Fix for 1 vulnerable dependencies (mdn#1294)
  text-transform: full-size-kana value (mdn#1289)
  renamed function findFirstLargeNumber to isLargeNumber (mdn#1293)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants