Java regex pattern not working as intended
<p>I am new to patterns and regex and have encountered a problem which I can't solve.
This is my code:</p>

<pre><code>public static void main(String[] args) {

    Pattern pattern = Pattern.compile("(!?)(fw|ri|le|cl|rs)[\\s,]*(\\d*\\.*\\d*|\"\\w*\")?[\\s,]*(\\d*\\.*\\d*|\"\\w*\")?[\\s,]*(\\d*\\.*\\d*|\"\\w*\")?");
    Matcher matcher = pattern.matcher("!fw 90.0 \"hello\" 70.0");

    matcher.find();
    for(int i = 0; i &lt; matcher.groupCount()+1; i++) {
        System.out.println("Group "+i+") " + matcher.group(i));
    }
}
</code></pre>

<p>So, i've used <a href="http://regexr.com" rel="nofollow">regexr.com</a> to create the regex, and on the website it works as planned. It should find 3 arguments which can be either a number or a String, where the String is enclosed in quotation mark. As I said, on <a href="http://regexr.com" rel="nofollow">regexr.com</a>
it works, however in java it does only, when there are no Strings. What am I doing wrong?
(The regex without the extra backslashes is
<code>(!?)(fw|ri|le|cl|rs)[\s,]*(\d*\.*\d*|"\w*")?[\s,]*(\d*\.*\d*|"\w*")?[\s,]*(\d*\.*\d*|"\w*")?</code> )</p>

<p>Thanks in advance.</p>

<p>Edit:
Some examples of what does happen and what doesn't:</p>

<p><strong>Working as intended:</strong></p>

<p>Input: <code>!fw 1.0 2.0 3.0</code></p>

<p>Ouput: <code>
Group 0) !fw 1.0 2.0 3.0
Group 1) !
Group 2) fw
Group 3) 1.0
Group 4) 2.0
Group 5) 3.0</code></p>

<p><strong>Not working as intended:</strong></p>

<p>Input: <code>!fw 1.0 \"hello\" 3.0</code></p>

<p>Output: 
<code>
Group 0) !fw 1.0 
Group 1) !
Group 2) fw
Group 3) 1.0
Group 4) 
Group 5)</code></p>

<p>Intended Output:
<code>
Group 0) !fw 1.0 "hello" 3.0
Group 1) !
Group 2) fw
Group 3) 1.0
Group 4) "hello"
Group 5) 3.0</code></p>