Regular expressions

Hi,

I am having a lot of fun with regular expressions :roll:
I want to do a replace on:
[tag]

  • beeing 0 or more characters (any character including white space stuff and any other stuff)
    [ beeing actually the bracket [

I am using the following regular expression```
/[.tag.]/g

If use the following tekst```
rekeningnummer [rekeningnummer] bij de [bankrelatie].Met een 
```with a replace using the RegExp```
/\[.*rekeningnummer.*\]/g
``` it will replace **[rekeningnummer] bij de [bankrelatie]** instead of only**[rekeningnummer]**

Any ideas of why this happens?

Thankx in advance
Paulo

Yes, .* is a ‘greedy’ search.

You can simply replace it with .*? and the search will be limited…

You are my hero :D

IT2Be:
Yes, .* is a ‘greedy’ search.

You can simply replace it with .*? and the search will be limited…