Question: I have an XML file that I want to format an XML file to remove tags like "`<scientific_max></scientific_max>`".
I used that code but it didn't work

```
String regex = "<([a-z_]+)></($1)>";
result = result.replaceAll(regex, "");

```

Have a nice day!

Answer: 
Because it is a local variable, not a global. That's the point of local variables.

`var a` creates a variable that exists for the life time of the function call. Declaring a function inside it extends the lifetime to cover that function too. When the anonymous function is called it continues to use the `a` that exists in the scope that it was created in.

Since you call the outer function twice, you have two `a`s. One for each call. You have two anonymous functions, one for each call. Each anonymous function was created in the same scope as one of the `a`s.
JavaScript variables are scoped by function declarations, not by blocks. Thus, you are using two different variables.