Java的String物件中,有個split function,
平常使用String.split("分隔字串")均可以將字串做分隔,
但,當原字串中,尾端若有連續出現的"分隔字串"時,
卻會被忽略。
例:
"a,b,c,d".split(",") = [a, b, c, d]
"a,b,c,d,,,".split(",") = [a, b, c, d]
但若改為
"a,b,c,d,,,".split(",", -1) = [a, b, c, d, "", "", ""]
原因為
"a,b,c,d,,,".split(",") = "a,b,c,d,,,".split(",", 0)
於是,尾端的空白值都會被忽略。
Java API Doc裡有提到:
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
2015年11月10日 星期二
2015年10月1日 星期四
2015年5月11日 星期一
Oracle listagg distinct
select col1,
regexp_replace(
listagg(col2, ',') within group (order by col2)
,'([^,]+)(,\1)+', '\1')
where rn = 1
group by col1;
ref from here
2015年3月27日 星期五
Oracle connection數上限 - 查詢
--The number of sessions the database was configured to allow
SELECT name, value
FROM v$parameter
WHERE name = 'sessions';
--The number of sessions currently active
SELECT COUNT(*)
FROM v$session;
訂閱:
文章 (Atom)