# How to parse bitstring?

**URL:** <https://forum.elixirforum.com/t/how-to-parse-bitstring/20403>\
**Category:** Questions\
**Tags:** nerves, troubleshooting, strings\
**Created:** [February 24, 2019, 4:00pm UTC](https://forum.elixirforum.com/t/how-to-parse-bitstring/20403 "2019-02-24T16:00:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kip](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/32/1440_2.png) [@kip](https://forum.elixirforum.com/u/kip)\
**Post date:** [February 24, 2019, 4:10pm UTC](https://forum.elixirforum.com/t/how-to-parse-bitstring/20403/2 "2019-02-24T16:10:39Z")

</div>

Something like this:

```elixir
iex> x = <<170, 192, 65, 0, 100, 0, 61, 86, 56, 171>>
iex> << _ :: bytes-4, onehundred :: bytes-1, _ :: bytes-1, sixtyone :: bytes-1, _rest :: binary >> = x          
<<170, 192, 65, 0, 100, 0, 61, 86, 56, 171>>
iex> onehundred
"d"
iex> sixtyone
"="

```

This assumes you want the fields as binaries. If you want them as integers:

```elixir
iex> << _ :: bytes-4, onehundred :: size(8), _ :: bytes-1, sixtyone :: size(8), _rest :: binary >> = x
<<170, 192, 65, 0, 100, 0, 61, 86, 56, 171>>
iex> sixtyone
61
iex> onehundred
100

```

---

_[View the full topic](https://forum.elixirforum.com/t/how-to-parse-bitstring/20403)._
