Question: I'm looking for good regex in java to get string url from all links and all emails. Now I have regex for links: 

```
 String linkRegex = "http[s]*://(\\w+\\.)*(\\w+)";
   Pattern pattern = Pattern.compile(linkRegex);

   Matcher matcher = pattern.matcher(stringAddres);

        while (matcher.find()) {
            String currentLink = matcher.group();
}

```

and I got links like: `http://twitter.com` but also I have `https://google`. So is there any way that I can remove links like `https://google`?

And I need regex that gives me email from string, for example: 
from this:

```
href="mailto:contact@example.com">contact@example.com</a></span> 

```

I should get only contact@example.com

Answer: 
> 
> 1) What is `vars()` doing in the below code
> 
> 
> 

Honestly, it's hard to tell. `vars()` (without an argument) returns the local namespace as a dictionary. In other words, it does the same thing as [`locals()`](https://docs.python.org/2/library/functions.html#locals). In your code, you then look up a name (`dict['H']`) in the locals dict and set an item in there. Setting an item in the dict returned by `locals()` does nothing if you are in a function... If you are in the global namespace, it adds an attribute.

> 
> 2) Why is the `vars()` necessary in front of the dictionary I created and could I leave it out?
> 
> 
> 

It probably isn't necessary and you probably *should* leave it out. Normally *dynamically* setting attributes on the global namespace is a really bad idea. You should generally pass around a dictionary of the data that you need instead. In other words, you *can* do:

```
v = 'foo'
globals()[v] = 'bar'
# ...
value = globals()[v]  # 'bar'

```

But you *shouldn't*. It's much better to just pass a dictionary around:

```
v = 'foo'
dct = {v: 'bar'}
# ...
value = dct[v]

```
First, you shouldn't overwrite `__builtin__` functions. `dict` is a reserved name for a function used to create dictionary objects.

Second, `var` gives you access to name declarations within the current running scope.