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: 
> 
> What is vars() actually doing in the below code?
> 
> 
> 

It does what it always does: it retrieves all local variables as a dictionary. That's how it works when calling `vars` *without* arguments.

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

It seems that someone is doing shenanigans with the local scope. It's just that it is wrapped with `dict['H']` which is just some variable (possibly `atom` is a string). In other words he's trying to retrieve a variable by dynamic name. For example

```
>>> test = 15
>>> x = 'test'
>>> vars()[x]
15

```

This should be **avoided** at all costs. Forget you even know about the existance of `vars()`. I do not know a single case when you have to use `vars()` instead of a dict or some other "normal" (and in this context safe) structure. The code you are looking at is insanely difficult to maintain, error prone and has serious security issues.
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.