user007
user007

Reputation: 3243

regex for getting text inside [bbcode]

How get the text inside a custom bbcode,

[gallery] get this text [/gallery].

I am using this regex but it wont work

/^(.*)\[gallery.*?\[\/gallery\](.*)$/gmi

Upvotes: 0

Views: 443

Answers (2)

pirs
pirs

Reputation: 2463

(new) try :

/\[gallery\](.*)\[\/gallery\]/g 

to return the value use

var result = str.match(regex); alert(result[1]);

Upvotes: 3

Tom Curran
Tom Curran

Reputation: 119

It looks like there may be some attributes after inside your tag.

Try this:

/\[gallery[^\]]*\](.*)\[\/gallery\]/gi

Upvotes: 0

Related Questions