小编Mar*_*ple的帖子

Java正则表达式如何找到父匹配?

来自维基百科的任何页面:

...
abas asdn asf asfs af
{{Template1
|a = Name surname
|b = jhsdf sdf
|c = {{Template2}}
|d = 
|e = [[f]] and [[g]]
|h = asd asdasfgasgasg asgas jygh trdx dftf xcth
|i = 73
|j = {{Template2|abc|123}}
|j = {{Template3|aa=kkk|bb={{Template4|cc=uu}}}}
}}

asd wetd gdsgwew g

{{OtherTemplate
|sdf = 213
}}
...
Run Code Online (Sandbox Code Playgroud)

如何使用Java正则表达式找到Template1内容(start is |aend is }})?

我试过了:

String pattern = "\\{\\{\\s*Template1\\s*(.*?)\\}\\}";

Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); …
Run Code Online (Sandbox Code Playgroud)

java regex string wikipedia match

7
推荐指数
1
解决办法
601
查看次数

如何使用htaccess拆分URL

例如:
google.com/en/game/game1.html
应该是
google.com/index.php?p1=en&p2=game&p3=game1.html

如何拆分网址并发送index.php"/"的一部分?

url .htaccess split

1
推荐指数
1
解决办法
3373
查看次数

Thread.sleep()和Object.sleep()之间的区别

我有一个功能:

Thread myThread = new Thread(new Runnable() {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(500);
                myThread.sleep(500);
            } catch (InterruptedException e) {
               e.printStackTrace();
            }
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

呼叫呼叫Thread.sleep(500);是一样的myThread.sleep(500);吗?

两个不同的电话之间有什么不同吗?

java multithreading runnable thread-sleep

1
推荐指数
1
解决办法
1791
查看次数

我应该将null设置为object以从内存中删除吗?

例如:

public class Box{
    public int id;

    public Box(int id){
        this.id = id;
    }
}

ArrayList<Box> boxArray = new ArrayList<Box>();

boxArray.add(new Box(0));
boxArray.add(new Box(1));
boxArray.add(new Box(2));

for (Iterator<Box> iter = boxArray.iterator(); iter.hasNext();) {
    Box box = iter.next();

    if (box.id == 1) {
        iter.remove();
        box = null;
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道:在Java中,当没有referance时,JM是删除对象.

  1. 我应该设置"box = null;" 从数组中删除它后,在此代码中对象?
  2. 我怎样才能确保该对象肯定会从JM中删除?

java jvm object

1
推荐指数
1
解决办法
710
查看次数