I'm trying to write a Regex of the form: najfo359f+-q3f#~[+0asa123123]a'/.df;ekfm345
This is what I have so far:
/.*[.*0*/d+].*/
But I can't match the simple [2245]
and when I try to escape \
the opening square bracket my code doesn't execute.
What am I missing?
A few observations:
0
in the middle of your regex seems a bit arbitrary and doesn't appear to be considered in any of your criteria./d
, maybe you meant \d
? A backslash \
is used to indicate escape sequences.You're looking for something more akin to:
/.*\[.*\d+\].*/
In context with Javascript:
const pattern = /.*\[.*\d+\].*/; console.log(pattern.test("najfo359f+-q3f#~[+0asa123123]a'/.df;ekfm345")); console.log(pattern.test("[2245]"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.