尝试使用正则表达式处理内容时, 需要小心替换字符串中是否包含:$ or /, 譬如:
Pattern pattern = Pattern.compile(“\\{C0\\}”);
Matcher matcher = pattern.matcher(“Price: [{C0}].”);
System.out.println(matcher.replaceAll(“€6.99”));
System.out.println(matcher.replaceAll(“$6.99”));
输出:
Price: [€6.99].
Exception in thread “main” java.lang.IndexOutOfBoundsException: No group 6
at java.util.regex.Matcher.group(Unknown Source)
at java.util.regex.Matcher.appendReplacement(Unknown Source)
at java.util.regex.Matcher.replaceAll(Unknown Source)
at TestExcel2Xml.main(TestExcel2Xml.java:10)
可见第一个replaceAll是正常工作的, 但第二个中的美元符号就出问题了.
Java API:
Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences as described above, and backslashes are used to escape literal characters in the replacement string.
可以使用Matcher.quoteReplacement(String)对替换内容进行预先处理: (API)
Returns a literal replacement String for the specified String. This method produces a String that will work use as a literal replacement s in the appendReplacement method of the Matcher class. The String produced will match the sequence of characters in s treated as a literal sequence. Slashes (‘\’) and dollar signs (‘$’) will be given no special meaning.
修改为:
Pattern pattern = Pattern.compile(“\\{C0\\}”);
Matcher matcher = pattern.matcher(“Price: [{C0}].”);
System.out.println(matcher.replaceAll(“€6.99”));
System.out.println(matcher.replaceAll(Matcher.quoteReplacement(“$6.99”)));
正确输出:
Price: [€6.99].
Price: [$6.99].
“doPDF is a free PDF converter for both personal and commercial use. Using doPDF you can create PDF files by selecting the “Print” command from virtually any application. With one click you can convert your Microsoft Excel, Word or PowerPoint documents or your emails and favorite web sites to PDF files.”
的确是轻巧好用的一款PDF打印机 — 如果你跟我一样, 只是需要简单的输出为PDF文件,那doPDF无疑是最佳选择,尤其是个人商用都免费!
>> Free Download <<
除此之外还有功能更为强大的novaPDF版本,而且还有面向开发人员的Toolkit, 更多信息: http://www.dopdf.com/
We are using Perforce for version control, I never use it before, and I got my perforce account those days. When I want update form the dept, perforce gave the following error:
Can’t clobber writable file Perforce
Here is the solution:
“A workaround is to stop perforce from making the files read-only on submit. This can be accomplished by changing the Client Specification and setting the “allwrite” flag. This way the files never go to readonly mode and you should be able to write to it always.”
we need to change one port when using Oracle 10g XE and Tomcat/JBoss, because they all use the 8080 port.
It’s very easy to change the web server port, just need to update some config xml file.
For Oracle, we just need to execute a SQL:
After connect to the server as sys admin, execute the following SQL:
begin
dbms_xdb.sethttpport(‘8888’);
end;
/
The port will be updated to 8888, no need to restart the oracle service.
When I try to install some plugins for my eclipse, there always some error like:
An error occurred while uninstalling
session context was:(profile=epp.package.java,
phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Uninstall,
operand=[R]org.apache.commons.lang 2.3.0.v200803061910 –>
[R]org.apache.commons.lang 2.3.0.v201005080501,
action=org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.UninstallBundleAction).
Error while loading manipulator.
Error while loading manipulator.
At first, I think maybe it’s because my proxy set up. but after try my times, I think maybe because my eclipse has been changed.
So I download a pure eclipse, and I can install the plugins now.
Then I check the config file of Eclipse(eclipse.ini), it has been modifed, and just few paramerters like: xms, xmx…I think it’s just because the config. and here is a bug page:https://bugs.eclipse.org/bugs/show_bug.cgi?id=325757(some one think it’s a bug)
And my solution is:
Check your eclipse config file(eclipse.ini), make sure it’s correct, see: http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.