I want to parse a string into something like an array:
ftp://user:pass@host:portpath
ftp://anon:1234@111.222.333.444:9999/path1/path2/
I read the java docs about using Pattern and Matcher but I keep getting an "IllegalStateException: No match found" error.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class test {
public static void main(String[] args) {
String s = "ftp://anon:bah@111.222.333.444:9999/path1/path2/";
Pattern p = Pattern.compile("^ftp://(/S+):(/S+)@(/S+):(/d+)(/S+)$");
Matcher m = p.matcher(s);
for (int i=0; i<m.groupCount(); i++)
System.out.println("Group"+i+": "+m.group(i));
}
}
"IllegalStateException: No match found" when it goes to print...
Help would be appreciated. Thnx in adv.