How to split the string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsreenathreddy
    New Member
    • Oct 2007
    • 40

    How to split the string

    Hi All,

    I have a requirement like which needs to split the string
    for example
    Code:
    String abcd="+44.968046+94.420307";
    Which needs to split like
    Code:
    a="+44.968046";
    b="+94.420307";
    Note we can have both only + or - symbols.

    Appreciate your help.

    Thanks,
    Last edited by Frinavale; Nov 17 '16, 09:43 PM. Reason: added code tags
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Please see the documentation for the String.split method and try to use it in your application to achieve what you are looking for.

    Comment

    • chaarmann
      Recognized Expert Contributor
      • Nov 2007
      • 785

      #3
      You can use regular expressions to split the string, too.
      In your case, use "[+-][\\d\\.]+" for splitting.

      Comment

      Working...