一个正则表达式的问题

I have the following string in PHP:

<p> [#form id=1]</p>

What is the pattern for getting it? I tried this:

/\<p\>\s\[\#.+?.\]\s\<\/p\>/

But it does not work. Any idea?

/\<p\>\s*\[\#.+?.\]\s*\<\/p\>/

You don't have space after ] , but regexp test for it

In the string there is nothing between ] and <

<p> [#form id=1]</p>
               ^^

But in your regex you've a \s (one whitespace character) between ] and <. Either drop the \s if you are sure there will be nothing between or change it to \s* if there can be any number of whitespace characters.

You don't have a space after the ] sign,

Have a try with :

~<p> \[#.+\]</p>~