MBehtemam
MBehtemam

Reputation: 7919

Regular Expression for extracting Content between bracket with some exception on selected contents

i want to extract contents between each brackets with some exception and the exception is if content has \ character the reg must doesn't select it. for first part i use this code :

var paramReg = /\[(.*?)\]/g;

this reg also select this string [param1] and [param2/p] string but this string [param2/p] has a \ in it's content and i don't want reg selected it . i know i can remove this kind of exception with for loop and then check for \ but i want to know can i use Reg for this.

Upvotes: 0

Views: 20

Answers (1)

Doug Knudsen
Doug Knudsen

Reputation: 954

How about this:

var paramReg = /\[([^\\]*?)\]/g;

Upvotes: 2

Related Questions