Hi I am new to regex and this can be a very simple question (hopefully).
I am trying to use one solution for three types of strings
- "45%", expected result: "45"
- "45", expected result: "45"
- ", Expected Result:" "
What I'm trying (let the string be str):
str.match(/(.*)(?!%*)/i)[1]
This in my head will sound like "match any instance of something to"% "if it is found, or just match something"
In the head of firebug, it seems more like that "it simply matches anything and completely ignores the negative look." Also, to make him lazy - (.*)? - doesn't seem to help.
We remember the second that in this particular situation I only compare numbers, therefore a /\d*/ . I am trying to understand a general rule so that I can apply it every time.
Would anyone be so kind as to help me?
javascript regex negative-lookahead
undefinederror
source share