# Any difference between : or , in the SubString() method?

**URL:** https://discourse.julialang.org/t/any-difference-between-or-in-the-substring-method/47215
**Category:** New to Julia
**Created:** [September 24, 2020, 3:04pm UTC](https://discourse.julialang.org/t/any-difference-between-or-in-the-substring-method/47215 "2020-09-24T15:04:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anon60034542](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon60034542](https://discourse.julialang.org/u/anon60034542)
#### Post date: [September 24, 2020, 3:04pm UTC](https://discourse.julialang.org/t/any-difference-between-or-in-the-substring-method/47215/1 "2020-09-24T15:04:04Z")

</div>

```julia
introduction = "Hello World"

standard_greeting = SubString(introduction, 1:5)
println(standard_greeting) # Will print Hello.

standard_greeting = SubString(introduction, 1,5)
println(standard_greeting) # Will print Hello.

```

1. Is there any difference between using `,` or `:` when using the` SubString()` method?

This is interesting, and I’m aware the Python is not Julia, but in Python, doing:

```python
introduction = "Hello World"
print(introduction[1:5].strip()) # Will print ello

```

In Julia:

```julia
introduction = "Hello World"
standard_greeting = SubString(introduction, :5) # Will print o World
println(standard_greeting)

```

Python:

```julia
introduction = "Hello World"
print(introduction[:5].strip()) # Will print Hello

```

1. In Julia, `:5` is equivalent as saying start at index 5, is that the correct way of thinking about it?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [September 24, 2020, 3:14pm UTC](https://discourse.julialang.org/t/any-difference-between-or-in-the-substring-method/47215/2 "2020-09-24T15:14:32Z")

</div>

> [@anon60034542](#):
>
> In Julia, `:5` is equivalent as saying start at index 5, is that the correct way of thinking about it?

The fact is `:5` is actually parsed by Julia as the integer 5, so you’re using the method where only one integer is passed, which means “from position 5 on”. Don’t think that `:5` represents any range, like Python does.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [September 24, 2020, 3:21pm UTC](https://discourse.julialang.org/t/any-difference-between-or-in-the-substring-method/47215/3 "2020-09-24T15:21:49Z")

</div>

> [@anon60034542](#):
>
> Is there any difference between using `,` or `:` when using the ` SubString()` method?

They look to be the same: [https://github.com/JuliaLang/julia/blob/a62acdfae164a706328426af9ff9ca73601e28c4/base/strings/substring.jl#L38-L40](https://github.com/JuliaLang/julia/blob/a62acdfae164a706328426af9ff9ca73601e28c4/base/strings/substring.jl#L38-L40)
