Error matching square bracket literal in string with JS regex

Sti555

New Member
I'm having an issue with matching a square bracket in a string with a regular expression in Javascript. I have tested the regex below, and it works for me:\[code\]"step_users[0]?[step]?[name]?".match(/step_users\[\d*\]/)\[/code\]This regex matches the substring "step_users[0]", but what I really need to match is the substring "step_users[0][step]". I tried modifying the regex as follows, but it fails for me.\[code\]/step_users\[\d*\]\[step\]/\[/code\]In fact, if i even add on the second '[', it fails. So, this also fails:\[code\]"step_users[0]?[step]?[name]?".match(/step_users\[\d*\]\[/)\[/code\]Why would it match '[' for the first square bracket, but fail on the second?
 
Top