Re: Regexp Octal question
On Jun 26, 9:23 am, hiwa <HGA03...@nifty.ne.jp> wrote:
On Jun 26, 6:28 am, julien <richard.jul...@gmail.com> wrote:
Hi,
Strange question, if somebody have an answer, will be really helpfull.
I used a regexp (octal) : < \0 > to find < (char)0 > char in a
string.
1) If i get the regexp \0 from a text file, the regexp NOT match.
2) If i defines directly the regexp \0 in java code, the regexp MATCH.
3) If i get regexp \x00 (another way to match (char)0) from a file,
the regexp MATCH
4) If i defines directly the regexp \x00 in java code, the regexp
MATCH
So, to resume, i cant successfull get the regexp from a file.
Any idea ? This case is really strange for me.
Thanks in advance.
I don't understand your question.
Post a small demo code that is generally compilable, runnable and
could reproduce your problem. See:http://homepage1.nifty.com/algafield/sscce.html
andhttp://www.yoda.arachsys.com/java/newsgroups.html
And there should be no problem. Try this code:
/*** content of the regex.txt file *************************
\0103
************************************************************/
import java.io.*;
public class Julien{
public static void main(String[] args) throws Exception{
String regexFromFile;
String regexFromCode = "\\0103";
String text = "ABCDEF";
BufferedReader br = new BufferedReader(new
FileReader("regex.txt"));
regexFromFile = br.readLine();
System.out.println(text.replaceAll(regexFromFile, "G"));
System.out.println(text.replaceAll(regexFromCode, "G"));
}
}