Spam Filter Step 20

hey been stuck on step 20 of the spam filter for like 4 hours - can some assist please.

Replace the first literal space with the \s* expression.

Replace the second literal space with \s+ expression

tried so many configurations including different brackets like (). {} and and can’t figure it out. Please explain like im 5 because this is confusing as hell.

my code:
const dollarRegex = /[0-9]+\s*(hundred|thousand|million|billion)?dollars\s+/i;

Welcome to the forum @novelbloglover

Here is a comparison of the original code and your code.

The code in blue is the original code, the code in red is your code.
The code in magenta is the overlap.

image

Replace the first literal space with the \s* expression. The \s character class matches whitespace, such as spaces, tabs, and new lines. The * quantifier means “match the previous character 0 or more times”. ✓

Replace the second literal space with \s+. The + quantifier means “match the previous character at least one time”. ✗

The second literal space is before the word dollar

Happy coding

i adjusted the position of the \s+ and it still gives me an error. Now i have this code:

const dollarRegex = /\s*[0-9](hundred|thousand|million|billion)?\s+dollars/i;

and this error:
Your dollarRegex must allow any number of spaces before the dollar quantity, and one or more spaces after.

Hi @novelbloglover

The first literal space was correct. Try changing it back.

I edited your post so the code formats correctly on the forum.

You need to place back ticks before and after code.
Here is a single back tick `

Happy coding

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.