Regex and java... not fun, help? (links and stuff)

Im trying to implement a regex for my game, my target is to read a file, and get relative links (they look like this : C:\windows\blah\blah)
and i want to replace all of the " \ " with " / " so it looks like (C://windows/blah/blah)

the problem i run into is java is throwing this nasty error:



java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
 ^
	at java.util.regex.Pattern.error(Unknown Source)
	at java.util.regex.Pattern.compile(Unknown Source)
	at java.util.regex.Pattern.<init>(Unknown Source)
blah blah


so, obviously it doesntl ike my regex code, here it is


for(int i=0;i<fileLines.size();i++){
				String tmp = (String)fileLines.get(i);     //file lines is an arraylist of strings 
//which is relative to the lins of the file
				String one = "\\";
				char o = 92;
				System.out.println((int)'\\');
				System.out.println(one+"HELLOWORLD");
				System.out.println("TTTTTTTTTTTTTTTTTTTTTTTT"+tmp);
				tmp.replaceAll(""+o, "/");
				System.out.println("TTTTTTTTTTTTTTTTTTTTTTTT"+tmp);
				//tmp.replaceAll("\\", "\\"+"\\");
				fileLines.set(i, tmp);
			}

can anyone tell me what im doig wrong and how to fix it?

There are two levels of escaping that you need. One to make a backslash character in a Java string ("\" is written in source code to get a string object with a single backslash)… and then you need two of those so the final regex string has two backslashes so the regex backslash is escaped with a backslash… clear as mud?

I think you are looking for something like this:

String blah 2 = blah.replaceAll("\\","/");

I figured it out…

i forgot to do this


tmp = tmp.replace('\\', '/');

dont you hate it when your mistake is soooo simple and you think its something really complex?

File.seperator ?