Splitting number

This topic contains 3 replies, has 3 voices, and was last updated by  Tony Antony 6 days, 13 hours ago.

  • Author
    Posts
  • #104395

    Tony Antony
    Participant

    I have a variable

    $t = "4459156205"

    I'm trying to split it into 4459 and 156205

    So I thought I would try

    $t[0..3]

    to get 4459, but I'm getting
    4
    4
    5
    9

    How can I get 4459

  • #104398

    Olaf Soyk
    Participant

    You can use the substring method if it's a string ... like this:

    "4459156205".Substring(0,4)
  • #104401

    Joel Sallow
    Participant

    You can also use -join

    -join $t[0..3]
  • #104402

    Tony Antony
    Participant

    Thank you

You must be logged in to reply to this topic.