# How to detect if a text starts with an another text?

**URL:** <https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022>\
**Category:** Questions about Thunkable X\
**Tags:** beginner, text\
**Created:** [April 5, 2022, 4:27pm UTC](https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022 "2022-04-05T16:27:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rixthetyrunt](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@rixthetyrunt](https://community.thunkable.com/u/rixthetyrunt)\
**Post date:** [April 5, 2022, 4:27pm UTC](https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022/1 "2022-04-05T16:27:49Z")

</div>

Hello, coding guys,

as you saw in the title of this first post, I would like to detect if a text, like “hello world” contains "hello " ( the space is not a mistake ) , like, a function, or something, I don’t know… I just literally heard “thunkable” for the first time.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 5, 2022, 4:38pm UTC](https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022/2 "2022-04-05T16:38:42Z")

</div>

> [@rixthetyrunt](#):
>
> d like to detect if a text, like “hello world” contains "hello " ( the space is not a mistake ) , like, a function, or something, I don’t know… I just literally heard “thunkable” for the first time.

Hey @rixthetyrunt 👋

Welcome to the community and Thunkable! What kind of app are you looking to build?

A combo you may find useful looks like:

 ![Screen Shot 2022-04-05 at 12.37.38 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/c/dc7fe3493cdde9b20067c028c88b9bbd2c00ddf0.png)

See it in action here and read more about text blocks [here](https://docs.thunkable.com/text)!

Happy thunking!

---

<div class="post-metadata">

**Author:** ![rixthetyrunt](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@rixthetyrunt](https://community.thunkable.com/u/rixthetyrunt)\
**Post date:** [April 5, 2022, 4:41pm UTC](https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022/3 "2022-04-05T16:41:07Z")

</div>

It seems like it doesn’t if a text **starts with** an another text, not **contains**.

EDIT: Oh, you can’t just put “https://” or “http://” or “puck:” in the middle of an URL like: scratch.mit.[https://edu](https://edu), that would be… A nonsense.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 5, 2022, 4:49pm UTC](https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022/4 "2022-04-05T16:49:48Z")

</div>

Sorry! I misunderstood.

check this out.

 ![Screen Shot 2022-04-05 at 12.45.30 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/2/d22ec93bd7446bea1105136281695a35e1ef2446.png)

The idea here is we check  
if extracted text = text to find  
set label text = ‘found’  
else  
set label text = ‘not found’

the special sauce here is the extracted text to compare. I extract, from the start, an equivalent number of characters from `the main text` as the number of characters in the `text to find`. I use the length of string block to find that length. I compare that substring or extracted text against the term to find and if they are equal, 1 set of logic occurs else, another set of logic occurs.

Read more about text blocks [here](https://docs.thunkable.com/text)!

Happy thunking!

---

<div class="post-metadata">

**Author:** ![rixthetyrunt](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@rixthetyrunt](https://community.thunkable.com/u/rixthetyrunt)\
**Post date:** [April 5, 2022, 5:09pm UTC](https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022/5 "2022-04-05T17:09:16Z")

</div>

I think this script is the solution:

 ![in text abc find first occurrence of text b = in text abc find last occurrence of text b](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/8/a84260954b78961a34b93bb8fc44677e7b7fc341.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [July 4, 2022, 5:10pm UTC](https://community.thunkable.com/t/how-to-detect-if-a-text-starts-with-an-another-text/1819022/6 "2022-07-04T17:10:06Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
