English 中文(简体)
如何确定这一 j
原标题:How to fix this java regex
  • 时间:2023-07-02 01:49:59
  •  标签:
  • java
  • regex

泽西岛

String regex = String.format("^%s(\$.+)?", entryNameToMatchWithRegex);

页: 1

我正在取得意想不到的结果,在伐木时,它像这样印刷了:

The regex for entry BLOCK_LEAK_22, is: ^BLOCK_LEAK_22($.+)?

为此,它应当努力:^>。 BLOCK_LEAK_22(/$.+)?

www.un.org/Depts/DGACM/index_spanish.htm 我的理解是,该日志正显示该日形形形形形形形形色色()的缩略语,表明该浮标有选择性,因此我需要它,因为例如,在核对有这种名字的日志时(测试组):

String[] testStrings  =  {
         "BLOCK_LEAK_22$55",
        "BLOCK_LEAK_22",
        "BLOCK_LEAK_22$1"};
for (String str : testStrings) {
    System.out.println(str + " -> " + str.matches("^BLOCK_LEAK_22(\$.+)?"));
}

它应当印刷:

BLOCK_LEAK_22$55 -> true
BLOCK_LEAK_22 -> true
BLOCK_LEAK_22$1 -> true

But since the regex is being like this: ^BLOCK_LEAK_22($.+)? then im getting this results (wrong):

BLOCK_LEAK_22$55 -> true
BLOCK_LEAK_22 -> false
BLOCK_LEAK_22$1 -> true
问题回答

你可以尝试:

str.matches("^BLOCK_LEAK_22(\\$.+)?")

添加2个斜线。

^%s(\\$.+)?

在 Java,在案文中,“<>条码/代码>的性质”被视为e爱籍特性>。

除此以外,还具有相关意义。

< rel=“nofollow noretinger”> 特征 (The JavaTM Tutorials > Learning the Java Language > Numbers and Strings)

页: 1 反弹之前的特性是逃逸的顺序,对汇编者具有特别的意义。 下表显示了 Java越航顺序:

http://www.un.org/Depts/DGACM/index_french.htm





相关问题
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 ...