I´m trying to make a regular expression to match a whitespace and so far I´m doing this:
Powered[\s]*[bB]y.*MyBB
I know it should work because I've tried it with Regex Buddy and it says it does but when I try to run it with Eclipse it marks an error saying it's not a valid escape sequence and it automatically adds 2 ´\´ rendering the regex useless....could someone tell me what to do? I've so far ended up using a point instead of \s but what I really need is the \s...
Thanks
Added:
Well, I understand but, I though '\s
' is used for any whitespace character and as I said, Regex Buddy also recognizes it as such, and if I use '\s
' it is not recognized in Regex Buddy hence the test fails, but in eclipse it allows me to go on, even though it matches nothing... =/ or did I not get something?
Exactly what do you mean with using a regular expression in Eclipse? Are you trying to do a search-and-replace in the IDE, or are you trying to use a regex in your Java code?
If you want to use a regex in Java code, generate a Java source code snippet on the Use tab in RegexBuddy, and paste that into your code.
If you want to get the regex alone ready to paste into Java code, select the Java flavor in the toolbar at the top in RegexBuddy. Then click the Copy button, and select Copy Regex as Java String. RegexBuddy will then copy your regex to the clipboard propertly formatted as a Java string. Your regex will be copied as:
"Powered[\\s]*[bB]y.*MyBB"
The extra backslash is essential when using a Java string literal to store your regex.
P.S.: You can use \s instead of [\s]. Saves two keystrokes.