I have written a simple script which goes through a textarea and transports !hash tags! and @person names@ into two separate inputs. 

However, unless the first of two regex conditions is met (word starts with '!' and ends with '!' symbol), it does not work for the next condition.

For example code on line 42 console.log(persons\_parsed); doesnt execute at all, unless !hash tag! typed into the textarea.

How to make it work, so I could only enter @person name@ and it would fill it in the input#persons\_jquery ?

Code in jsfiddle: <http://jsfiddle.net/Yz2jw/1/>

The problematic part

```
if (tags_parsed.length > 0) {

        var vysledek_tags = null;
        for (i = 0; i < tags_parsed.length; i++) {
            if (vysledek_tags) {
                var vysledek_tags = vysledek_tags + ', ' + tags_parsed[i].replace(/[!]/g, '');
            } else {
                var vysledek_tags = tags_parsed[i].replace(/[!]/g, '');
            }
        }
        $('#tags_jquery').val(vysledek_tags);

    }
    console.log(persons_parsed); // THIS DOESNT RETURN ANY VALUE!!!

    if (persons_parsed.length > 0) {

        var vysledek = null;
        for (i = 0; i < persons_parsed.length; i++) {
            if (vysledek) {
                var vysledek = vysledek + ', ' + persons_parsed[i].replace(/[@]/g, '');
            } else {
                var vysledek = persons_parsed[i].replace(/[@]/g, '');
            }
        }
        $('#persons_jquery').val(vysledek);

```

Thank you, 
Jakub