Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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,我有条件: @Table(name = "T_MEM_MEMBER_ADDRESS1") @Table( name = "T_MEM_MEMBER_ADDRESS2") @Table ( name = "T_MEM_MEMBER_ADDRESS3" ) 我想编写一个regex,它可以获取name值,例如: T_MEM_MEMBER_ADDRESS1 T_MEM_MEMBER_ADDRESS2 T_MEM_MEMBER_ADDRESS3 我写 String regexPatt

我有条件:

 @Table(name = "T_MEM_MEMBER_ADDRESS1")
 @Table(  name = "T_MEM_MEMBER_ADDRESS2")
 @Table (   name = "T_MEM_MEMBER_ADDRESS3" )
我想编写一个regex,它可以获取name值,例如:

 T_MEM_MEMBER_ADDRESS1
 T_MEM_MEMBER_ADDRESS2
 T_MEM_MEMBER_ADDRESS3
我写

String regexPattern="...";
Pattern pattern = Pattern.compile(regexPattern);
Matcher matcher = pattern.matcher(input);

boolean matches = matcher.matches();
if (matches){
   log.debug(matcher.group(1));
}

但是我无法编写regexpatern..

您可以使用此正则表达式:

(?<=")(.+)(?=")

(?您可以使用这段代码:

    String input = "@Table(name = \"T_MEM_MEMBER_ADDRESS1\")";
    String regexPattern=".*\"(.*)\".*";
    Pattern pattern = Pattern.compile(regexPattern);
    Matcher matcher = pattern.matcher(input);

    boolean matches = matcher.matches();
    if (matches){
       System.out.println(matcher.group(1));
    }

希望有帮助。

你仍然需要避开引号:
”(?如果我不想匹配
/@Table(name=“t\u MEM\u MEMBER\u ADDRESS”)
/@Table(name=“t\u MEM\u MEMBER\u ADDRESS”)
,如何写?@AmitJoki我的意思是,如果我的字符串也有
/@Table(name=“t\u MEM\u MEMBER\u ADDRESS”)
对于//注释,我不希望我的regexpatern与此字符串匹配
    String input = "@Table(name = \"T_MEM_MEMBER_ADDRESS1\")";
    String regexPattern=".*\"(.*)\".*";
    Pattern pattern = Pattern.compile(regexPattern);
    Matcher matcher = pattern.matcher(input);

    boolean matches = matcher.matches();
    if (matches){
       System.out.println(matcher.group(1));
    }