# Remove leading zeros from string to int

**URL:** <https://discourse.julialang.org/t/remove-leading-zeros-from-string-to-int/82048>\
**Category:** General Usage\
**Tags:** strings, parsing, missing-values\
**Created:** [June 1, 2022, 10:48am UTC](https://discourse.julialang.org/t/remove-leading-zeros-from-string-to-int/82048 "2022-06-01T10:48:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [June 1, 2022, 11:43am UTC](https://discourse.julialang.org/t/remove-leading-zeros-from-string-to-int/82048/2 "2022-06-01T11:43:40Z")

</div>

Getting an integer from a string is parsing, so you should use `parse`:

```julia
julia> parse(Int64, "001")
1

```

In your case you’d have to combine it with passmissing as shown, so:

```julia
julia> passmissing(parse).(Int64, ["001", "012", missing, "002"])
4-element Vector{Union{Missing, Int64}}:
  1
 12
   missing
  2

```

---

_[View the full topic](https://discourse.julialang.org/t/remove-leading-zeros-from-string-to-int/82048)._
