例如,我有前边界'x'和后边界'y'
EG给定一个字符串'abcxfoobaryblablah',它应该返回'foobar'.
假设两个边界在字符串中只出现一次,就像在示例中一样.
谢谢!不必使用正则表达式,但我想这是最好的方法.
String s = "abcxfoobaryblablah";
s = s.substring(s.indexOf('x') + 1, s.indexOf('y'));
System.out.println(s);
Run Code Online (Sandbox Code Playgroud)
退房
foobar
Run Code Online (Sandbox Code Playgroud)