{"id":86,"date":"2023-02-14T21:34:57","date_gmt":"2023-02-14T13:34:57","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=86"},"modified":"2023-02-14T21:36:03","modified_gmt":"2023-02-14T13:36:03","slug":"java-regular-expression-matches-one-or-more-spaces","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/14\/java-regular-expression-matches-one-or-more-spaces\/","title":{"rendered":"Java\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u7a7a\u683c"},"content":{"rendered":"<p>\uff081\uff09\u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u7a7a\u683c\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a<code>\\\\s+<\/code><\/p>\n<pre><code class=\"language-java\">String[] newStr = str.trim().split(&quot;\\\\s+&quot;);<\/code><\/pre>\n<p>\uff082\uff09\u5339\u914d\u4e8c\u4e2a\u6216\u591a\u4e2a\u7a7a\u683c\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a<code>\\\\s{2,}<\/code><\/p>\n<pre><code class=\"language-java\">String str = new String(&quot;I am   a   good     boy!    &quot;);\nString newStr = str.replaceAll(&quot;\\\\s{2,}&quot;, &quot; &quot;).trim();<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uff081\uff09\u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u7a7a\u683c\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a\\\\s+ String[] newStr = str.trim().sp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[54],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-java-basic","tag-regular"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}