Java GWT-提取两个字符之间的文本

Java GWT-提取两个字符之间的文本,java,regex,gwt,substring,Java,Regex,Gwt,Substring,在GWT中,我有一个servlet,它将图像从数据库返回到客户端。我需要提取字符串的一部分以正确显示图像。chrome、firefox和IE中返回的内容在src部分有一个斜杠。例如:字符串s=src=\;在下面的字符串中不可见。也许斜杠在http字符串周围添加了更多的括号。我不确定 what is returned in those 3 browsers is = <img style="-webkit-user-select: none;" src="http://localhost

在GWT中,我有一个servlet,它将图像从数据库返回到客户端。我需要提取字符串的一部分以正确显示图像。chrome、firefox和IE中返回的内容在src部分有一个斜杠。例如:字符串s=src=\;在下面的字符串中不可见。也许斜杠在http字符串周围添加了更多的括号。我不确定

  what is returned in those 3 browsers is = <img style="-webkit-user-select: none;" src="http://localhost:8080/dashboardmanager/downloadfile?entityId=4886">
使用src=或src=\

我在返回时不带括号的浏览器上尝试和使用的内容src=\:

String s = "src=\"";
int index = returned.indexOf(s) + s.length();
image.setUrl(returned.substring(index, returned.indexOf("\"", index + 1)));
但在EDGE中无法工作,因为它不返回斜杠

我无法访问GWT中的模式和匹配器

如何提取并记住entityId号将发生变化

上面返回的字符串是什么

编辑:

我需要一个通用的方法来提取

当字符串在两个方向上看起来都是这样时

String edge = "<img src=”http://localhost:8080/dashboardmanager/downloadfile?entityId=4886”>";

3 browsers is = <img style="-webkit-user-select: none;" src="http://localhost:8080/dashboardmanager/downloadfile?entityId=4886">

在edge中,其字符串toParse=;我需要一种方法来提取http部分。不管字符串是如何开始的。如果您更改的toParse声明为:string toParse=;不,你上面贴的那个有斜杠,但不应该也不会有。第一个有斜杠,第二个没有。示例字符串toParse=;您的示例是否使用斜杠而不使用斜杠?斜杠仅用于转义字符串声明中的双引号。所以是的,它会的。
String s = "src=\"";
int index = returned.indexOf(s) + s.length();
image.setUrl(returned.substring(index, returned.indexOf("\"", index + 1)));
String edge = "<img src=”http://localhost:8080/dashboardmanager/downloadfile?entityId=4886”>";

3 browsers is = <img style="-webkit-user-select: none;" src="http://localhost:8080/dashboardmanager/downloadfile?entityId=4886">
    public static void main(String[] args) {
        String toParse = "<img style=\"-webkit-user-select: none;\" src=\"http://localhost:8080/dashboardmanager/downloadfile?entityId=4886\">";    
        String delimiter = "src=\"";
        int index = toParse.indexOf(delimiter) + delimiter.length();
        System.out.println(toParse.substring(index, toParse.length()).split("\"")[0]);      
    }