* chore(learn): audit basic algorithm scripting * chore(learn): audit basic data structures * chore(learn): audit basic javascript * chore(learn): audit debugging * chore(learn): audit es6 * chore(learn): audit functional programming * chore(learn): audit intermidate algorithms * chore(learn): audit js projects * chore(learn): audit object oriented programming * chore(learn): audit regex * fix(learn): remove stray . * fix(learn): string to code * fix(learn): missed some * fix(learn): clarify strings Based on Randy's feedback, clarifies string instances where quotes were removed in favour of back ticks. * fix: apply suggestions - thanks Randy! :) Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: non-suggestion comments * chore(learn): remove comments from codes Removes the comments from the description and instruction code blocks to ensure that all relevant information is translatable. * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: revert crowdin fix * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * chore: change voice * fix: Christopher Nolan * fix: expressions would evaluate * fix: will -> would * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: to work to push * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
		
			
				
	
	
		
			92 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| id: 587d7db9367417b2b2512ba5
 | |
| title: Specify Upper and Lower Number of Matches
 | |
| challengeType: 1
 | |
| forumTopicId: 301367
 | |
| dashedName: specify-upper-and-lower-number-of-matches
 | |
| ---
 | |
| 
 | |
| # --description--
 | |
| 
 | |
| Recall that you use the plus sign `+` to look for one or more characters and the asterisk `*` to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns.
 | |
| 
 | |
| You can specify the lower and upper number of patterns with <dfn>quantity specifiers</dfn>. Quantity specifiers are used with curly brackets (`{` and `}`). You put two numbers between the curly brackets - for the lower and upper number of patterns.
 | |
| 
 | |
| For example, to match only the letter `a` appearing between `3` and `5` times in the string `ah`, your regex would be `/a{3,5}h/`.
 | |
| 
 | |
| ```js
 | |
| let A4 = "aaaah";
 | |
| let A2 = "aah";
 | |
| let multipleA = /a{3,5}h/;
 | |
| multipleA.test(A4);
 | |
| multipleA.test(A2);
 | |
| ```
 | |
| 
 | |
| The first `test` call would return `true`, while the second would return `false`.
 | |
| 
 | |
| # --instructions--
 | |
| 
 | |
| Change the regex `ohRegex` to match the entire phrase `Oh no` only when it has `3` to `6` letter `h`'s.
 | |
| 
 | |
| # --hints--
 | |
| 
 | |
| Your regex should use curly brackets.
 | |
| 
 | |
| ```js
 | |
| assert(ohRegex.source.match(/{.*?}/).length > 0);
 | |
| ```
 | |
| 
 | |
| Your regex should not match the string `Ohh no`
 | |
| 
 | |
| ```js
 | |
| assert(!ohRegex.test('Ohh no'));
 | |
| ```
 | |
| 
 | |
| Your regex should match the string `Ohhh no`
 | |
| 
 | |
| ```js
 | |
| assert('Ohhh no'.match(ohRegex)[0].length === 7);
 | |
| ```
 | |
| 
 | |
| Your regex should match the string `Ohhhh no`
 | |
| 
 | |
| ```js
 | |
| assert('Ohhhh no'.match(ohRegex)[0].length === 8);
 | |
| ```
 | |
| 
 | |
| Your regex should match the string `Ohhhhh no`
 | |
| 
 | |
| ```js
 | |
| assert('Ohhhhh no'.match(ohRegex)[0].length === 9);
 | |
| ```
 | |
| 
 | |
| Your regex should match the string `Ohhhhhh no`
 | |
| 
 | |
| ```js
 | |
| assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);
 | |
| ```
 | |
| 
 | |
| Your regex should not match the string `Ohhhhhhh no`
 | |
| 
 | |
| ```js
 | |
| assert(!ohRegex.test('Ohhhhhhh no'));
 | |
| ```
 | |
| 
 | |
| # --seed--
 | |
| 
 | |
| ## --seed-contents--
 | |
| 
 | |
| ```js
 | |
| let ohStr = "Ohhh no";
 | |
| let ohRegex = /change/; // Change this line
 | |
| let result = ohRegex.test(ohStr);
 | |
| ```
 | |
| 
 | |
| # --solutions--
 | |
| 
 | |
| ```js
 | |
| let ohStr = "Ohhh no";
 | |
| let ohRegex = /Oh{3,6} no/; // Change this line
 | |
| let result = ohRegex.test(ohStr);
 | |
| ```
 |