You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by time_crossing <ti...@163.com> on 2021/12/03 12:50:37 UTC
Re: [Lang]Consult
Thanks for response.
I know
System.out.println(StringUtils.split(code,"_")[1]);
Will retrun expected result.
But I think when I use
String code = "constant_true";
System.out.println(StringUtils.split(code,"constant_")[0]);
At first I thought return is (“" and “true”)
In fact this code will return what I say:
class Solution{
public static void main(String[] args) {
String code = "constant_true";
System.out.println(code.split("constant_")[1]);
}
}
On 12/3/2021 20:41,Marco Neumann<ma...@gmail.com> wrote:
it's not splitting anything this will.
This will:
System.out.println(StringUtils.split(code,"_")[1]);
On Fri, Dec 3, 2021 at 12:29 PM time_crossing <ti...@163.com> wrote:
Hi.
When I write this code:
class Solution{
public static void main(String[] args) {
String code = "constant_true";
System.out.println(StringUtils.split(code,"constant_")[0]);
}
}
I hope it retrun “true".
But it return “rue”.
Is it a bug? Should I try to fix it?
--
---
Marco Neumann
KONA
Re: [Lang]Consult
Posted by Alex P <st...@gmail.com>.
You need to use "splitByWholeSeparator" instead of "split"
https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#splitByWholeSeparator-java.lang.String-java.lang.String-
On Fri, Dec 3, 2021 at 7:50 AM time_crossing <ti...@163.com> wrote:
>
> Thanks for response.
> I know
> System.out.println(StringUtils.split(code,"_")[1]);
>
> Will retrun expected result.
> But I think when I use
> String code = "constant_true";
> System.out.println(StringUtils.split(code,"constant_")[0]);
>
>
> At first I thought return is (“" and “true”)
> In fact this code will return what I say:
> class Solution{
> public static void main(String[] args) {
> String code = "constant_true";
> System.out.println(code.split("constant_")[1]);
>
> }
> }
> On 12/3/2021 20:41,Marco Neumann<ma...@gmail.com> wrote:
> it's not splitting anything this will.
>
> This will:
>
> System.out.println(StringUtils.split(code,"_")[1]);
>
> On Fri, Dec 3, 2021 at 12:29 PM time_crossing <ti...@163.com> wrote:
>
>
>
> Hi.
> When I write this code:
> class Solution{
> public static void main(String[] args) {
> String code = "constant_true";
> System.out.println(StringUtils.split(code,"constant_")[0]);
>
>
> }
> }
>
>
> I hope it retrun “true".
> But it return “rue”.
> Is it a bug? Should I try to fix it?
>
>
>
> --
>
>
> ---
> Marco Neumann
> KONA
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org