Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从rtf字符串java中提取字符串内容_Java_Regex_Rtf - Fatal编程技术网

从rtf字符串java中提取字符串内容

从rtf字符串java中提取字符串内容,java,regex,rtf,Java,Regex,Rtf,我有以下rtf字符串:\af31507\ltrch\fcs0\insrsid6361256研究标题:{testfor14431过程\u88051000测试2 14432\u88058000}}{\rtlch\fcs1\af31507\ltrch\fcs0\insrsid1223827,我想提取研究标题ie的内容(研究标题:{测试14431进程\u8805 1000测试2 14432\u8805 8000})。下面是我的代码 String[] arr = value.split("\\s+");

我有以下rtf字符串:
\af31507\ltrch\fcs0\insrsid6361256研究标题:{testfor14431过程\u88051000测试2 14432\u88058000}}{\rtlch\fcs1\af31507\ltrch\fcs0\insrsid1223827
,我想提取研究标题ie的内容(
研究标题:{测试14431进程\u8805 1000测试2 14432\u8805 8000}
)。下面是我的代码

String[] arr = value.split("\\s+");
//System.out.println(arr.length);
for(int j=0; j<arr.length; j++) {
    if(isNumeric(arr[j])) {
         arr[j] = "\\?" + arr[j];
    }
}
String[]arr=value.split(\\s+);
//系统输出打印长度(arr.length);

对于(int j=0;j
学习标题:{[^}]*}
将符合您的期望。演示:

输出:

Study Title: {Test for 14431 process\'27s \u8805 1000 Testing2 14432 \u8805 8000}
根据OP ask更新

String s = "{\\af31507 \\ltrch\\fcs0 \\insrsid6361256 Study Title: {Test for 14431 process\\'27s \\u8805 1000 Testing2 14432 \\u8805 8000}}{\\rtlch\\fcs1 \\af31507 \\ltrch\\fcs0 \\insrsid12283827";
    Pattern p = Pattern.compile("(?<=Study Title: \\{)[^}]*(?=\\})");
    Matcher m = p.matcher(s);
    while (m.find()) {
        System.out.println(m.group());
    }

Test for 14431 process\'27s \u8805 1000 Testing2 14432 \u8805 8000
String s=“{\\af31507\\ltrch\\fcs0\\insrsid6361256研究标题:{14431过程测试\\'27s\\u8805 1000测试2 14432\\u8805 8000}}{\\rtlch\\fcs1\\af31507\\ltrch\\fcs0\\insrsid2283827”;

模式p=模式。编译(“(?建议您使用RTF解析器。请参阅。您好@Andrea我可以使用RTF解析器,但是我不确定我是否可以获得unicode字符,因为我想更新我的研究标题字符串的内容。这就是我不使用RTF解析器的原因,因为它将显示没有unicode字符的纯文本@yudong谢谢您的回答。我如何获得只有像“testfor14431 process'27s\u88051000 Testing2 14432\u88058000”一样,没有研究标题,也没有开始“{”和结束“}”?@shanky,只需将模式更新为(?Hi@yudong its giving me java.util.regex.PatternSyntaxException:非法重复错误
String s = "{\\af31507 \\ltrch\\fcs0 \\insrsid6361256 Study Title: {Test for 14431 process\\'27s \\u8805 1000 Testing2 14432 \\u8805 8000}}{\\rtlch\\fcs1 \\af31507 \\ltrch\\fcs0 \\insrsid12283827";
    Pattern p = Pattern.compile("(?<=Study Title: \\{)[^}]*(?=\\})");
    Matcher m = p.matcher(s);
    while (m.find()) {
        System.out.println(m.group());
    }

Test for 14431 process\'27s \u8805 1000 Testing2 14432 \u8805 8000