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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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
Java 如何从子字符串模式获取整个字符串值_Java_Regex - Fatal编程技术网

Java 如何从子字符串模式获取整个字符串值

Java 如何从子字符串模式获取整个字符串值,java,regex,Java,Regex,我需要从子字符串中获取字符串 String whlval = "I have stackoverflow accounts and i use to login from different users i.e Angel23552 wow isn't it"; 所以我想从Angel检索整个值“Angel23552”,即结果为“Angel23552” 条件:- 我只能使用Angel字符串从字符串whlval as中检索值 23552是随机值 上面的字符串,即

我需要从子字符串中获取字符串

String whlval = "I have stackoverflow accounts and i use to login from different users 
                 i.e Angel23552 wow isn't it";
所以我想从Angel检索整个值“Angel23552”,即结果为“Angel23552”

条件:-

  • 我只能使用Angel字符串从字符串whlval as中检索值
    23552是随机值
  • 上面的字符串,即whlval在两个字符串之间有不同的空格间隔

  • 像这样的东西对你有用吗

    String result = whlval.replaceAll(".*(Angel[^\\s]*).*","$1");
    
    嗯,也许:

    String[] split = StringUtils.split("I have   stackoverflow    accounts and i use to login from different   users  i.e Angel23552 wow isn't    it");
    

    然后在循环中,您可以尝试使用StringUtils.contains(CharSequence seq,CharSequence searchSeq)-返回true或false


    展示你所做的……谢谢……StringUtils有很多非常有用的API。我的坏
    replace
    不使用regexp,
    replaceAll
    使用regexp。