I have a block of text in php, and I want to be able to extract all hashtags and twitter names from it, and print them as one new string.

For example:

```
$longstring = "blah blah blah #hashtag blah blah @twittername blah email@email.com blah blah #hashtag2 blah blah";

```

And I want to create one new string:

```
$extracted = "#hashtag @twittername #hashtag2";

```

Any idea how I can do this easily?

I'm not sure if the answer is a regex? Can that do both together and find all multiple occurrences of both types?