My code:
const applyFunction = str => {
const noHigh = highPrecedence(str);
const infix = /([\d]+(.[\d]+)?)([+|-])([\d]+(.[\d]+)?)/
}
Link to the Step
Console is returning
Your first capture group should match one or more digits or decimal points. Use the \d character class.
Ive tested regex in a regex tester and it seems to be working, catching decimals and whatnot.
Any help would be appreciated
ILM
February 3, 2025, 8:51pm
2
you do not need to use []
to define a character class if you are already using \d
1 Like
const applyFunction = str => {
const noHigh = highPrecedence(str);
const infix = /(\d+(.\d+)?)(+|-)(\d+(.\d+)?)/
}
After applying that change, the console reverts back to step 5
Your first capture group should use a character class.
ILM
February 3, 2025, 8:58pm
4
the first capture group starts where you have the first (
… maybe you have an extra one?
ILM
February 3, 2025, 9:01pm
5
the regex requested by the step is simpler than what you are doing, you will need three capture groups, the middle one matching the +
or -
using a character class (not the |
), the first and last will be equal, you don’t need to worry about building a number, only to accept digits and period
Thanks for the response. For some reason, \d is not being recognized as a character class, I will keep trying with the advice you provided
I’m stuck on the first capture group
const infix = /(\d+.\d+)([\+-])/
Still returns
Your first capture group should use a character class.
Removing square brackets prompts for character class
ILM
February 3, 2025, 10:31pm
10
use the character class with []
to put together digts and period, do not build a number, just allow them in any order