<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="71677" data-post-id="71677">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="idi527" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  idi527
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<pre data-code-wrap="elixir"><code class="lang-elixir">@input    &lt;&lt;116, 114, 117, 101, 32, 105, 115, 32, 110, 111, 116, 32, 102, 97, 108, 115, 101&gt;&gt;
@true_    &lt;&lt;116, 114, 117, 101&gt;&gt;
@false_   &lt;&lt;102, 97, 108, 115, 101&gt;&gt;

def match_bitsting(&lt;&lt;@true_, rest::bits&gt;&gt;) do # bits is an alias for bitstring
  IO.puts "I got: true"
  match_continue(rest, true)
end

def match_bitsting(&lt;&lt;@false_, rest::bits&gt;&gt;) do
  IO.puts "I got: false"
  match_continue(rest, false)
end
</code></pre>
<p>Would this work for you?</p>
<p>Why are you using <code>bitstring</code>s anyway? What you have in <code>@input</code> is a (printable) <code>binary</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="71677" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-do-i-pattern-match-part-of-string-as-bitstrings/12750/4">Post #3</a>
	                </div>
	            </div>
              <div id="likers-container-71677" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="71677"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="71676" data-post-id="71676">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DimWell" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DimWell
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="grych" data-post="2" data-topic="12750">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/grych/48/5610_2.png" class="avatar"> grych:</div>
<blockquote>
<p>If I understood the problem properly, you want to match the beginning of the input string?</p>
</blockquote>
</aside>
<p>Not really, probably I have to change description a bit…</p>
<p>I have an input that looks like:</p>
<blockquote>
<p><code>&lt;&lt;116, 114, 117, 101, 32, 105, 115, 32, 110, 111, 116, 32, 102, 97, 108, 115, 101, 32, 97, 110, 100, 32, 102, 97, 108, 115, 101, 32, 105, 115, 32, 110, 111, 116, 32, 116, 114, 117, 101&gt;&gt;</code></p>
</blockquote>
<p>I want to do pattern match on:</p>
<p><code>&lt;&lt;116, 114, 117, 101&gt;&gt; # which is "true" and the rest data loop froward and match according other principles</code></p>
<p>Furthermore, this just dummy input just to explain the idea, the input can be any text…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="71676" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-do-i-pattern-match-part-of-string-as-bitstrings/12750/3">Post #2</a>
	                </div>
	            </div>
              <div id="likers-container-71676" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="71676"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #2"></div>
  </section>
</div>
    <div class="postbit" id="71675" data-post-id="71675">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="grych" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/grych/120/5610_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  grych
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Drab</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If I understood the problem properly, you want to match the beginning of the input string? In this case, it is easy:</p>
<pre><code>def match_bitstring("true" &lt;&gt; _rest), do: IO.puts("true")
def match_bitstring("false" &lt;&gt; _rest), do: IO.puts("false")
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="71675" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-do-i-pattern-match-part-of-string-as-bitstrings/12750/2">Post #1</a>
	                </div>
	            </div>
              <div id="likers-container-71675" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="71675"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-first-post cat-first-post" title="First post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>