Question: As part of a project, I need to analyse string which may contain a reference to PHP in the following manner:

`[php]functionName(args1, args2)[/php]`

The function name is not always the same, and I would like to replace everything in the above example (including the pseudo-tags) with another value. 

Can anyone suggest a Regular Expression to effectively match the pattern `[php]anything[/php]`. 

Sorry if this is a basic question, but I suck at Regular Expressions!

Answer: 
**If** constructs like `[ php ]`, `[/*comment/*php]` (or other crazy stuff) are not allowed, you can use this:

```
/\[php\](.*?)\[\/php\]/

```

The first matched group will be the text inside the tags. I think the regex is quite intuitive, except for the `?`: it will be lazy and match text only until the first closing tag, so that if you have `[php]...[/php] [php]...[/php]` the regex will not match `...[/php] [php]...` (that is, between the first `[php]` and the second `[/php]`)
You can search for string between these tags eg

```
\[PHP\](.+[^\b\[])\[/PHP\]

```