English 中文(简体)
将数据从数字证书中分离出的两个方括号?
原标题:Getting the data between two square brackets in java from a digital certificate?
  • 时间:2011-03-18 00:15:39
  •  标签:
  • java
  • regex
Pattern patronValidity = Pattern.compile("Validity: \[(.*?)\]");
            Matcher matcherValidity = patronValidity.matcher(strCert);
            if(matcherValidity.find()){
                System.out.println(matcherValidity.group(1));
            }

用于扫描档案的Im, 但没有交回。 奇怪的是,接下来的人确实回去了东西,但那是错的,因为左头盔仍然处于胎儿之中。

Pattern patronValidity = Pattern.compile("Validity: (\[[^]]*)");
            Matcher matcherValidity = patronValidity.matcher(strCert);
            if(matcherValidity.find()){
                System.out.println(matcherValidity.group(1));
            }

这是I m试图匹配的价值。

这从档案中可以看出:

Validity: [From: Thu Aug 21 10:22:08 CDT 2008,
               To: Sat Aug 21 10:22:08 CDT 2010]

To this as in the output from the second function:

[From: Thu Aug 21 10:22:08 CDT 2008,
               To: Sat Aug 21 10:22:08 CDT 2010

第一项职能与任何内容相对应。

最佳回答

各位:

Pattern patronValidity = Pattern.compile("\[([^\]]+)]");

你们需要什么!

问题回答

您第一次表示不工作的原因是but相吻合。 新的线性特征(以及可能的话)。 贵方需要汇编您的国旗,使其符合所有特性。 第二,见Scott的答复。

Does it have to be regex? I would probably just use substringing for a problem of this kind.

String str = "Validity: [From: Thu Aug 21 10:22:08 CDT 2008,
               To: Sat Aug 21 10:22:08 CDT 2010]";
System.out.println(str.substring(
                     str.indexOf( [ , str.indexOf("Validity: ")),
                     str.indexOf( ] )+1)
                  );

这应使预期产出更加容易阅读、更新、改变或扩大。 而且,我不肯定的是,在贾瓦邦,记忆库的用途有多少,而对于PHP来说,他们建议为此类工作提供内在功能,因为该系统的热量更大,而且速度也较慢。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签