# Search for letters in a string

**URL:** <https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [April 9, 2021, 4:06pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741 "2021-04-09T16:06:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaftPooch](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daftpooch/32/114199_2.png) [@DaftPooch](https://forum.dynamobim.com/u/DaftPooch)\
**Post date:** [April 9, 2021, 4:06pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/1 "2021-04-09T16:06:25Z")

</div>

Hey guys, I’m looking to be able to filter (like true or false) a list if it has a letter in it.

What I’m trying to achieve:  
I am going to replace all the Mark Values with Element ID. I got that script to work no problem.

Issue is, before i can apply this script i have to search the Mark Values and make sure no one has put a “comment” in it. Typically it is something like “Panel xyz needs to be connected to wrx”. In any case, it could be a mix of letters and numbers. Since the Mark Value should ONLY contain numbers, i want to be able to filter all my marks by separating the ones that have this potential comment in there.

I tried different methods. I just do not think i have my head around a way to filter by letters. Here is what i have done (I’ve tried different approaches but don’t have it on this clip)

 ![search for letters](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/a/2a02f7643534048bab6b6ace961b76c24f192c94.png)

Let me know if there is a node, method or even a thread i can look in.

I highly appreciate your time and help and am learning every time i come here. Thank you for your time.

---

<div class="post-metadata">

**Author:** ![Robert\_Younger](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/robert_younger/32/205603_2.png) [@Robert\_Younger](https://forum.dynamobim.com/u/Robert_Younger)\
**Post date:** [April 9, 2021, 4:17pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/2 "2021-04-09T16:17:20Z")

</div>

Use cross product instead of @L1 for the String.Contains node. This will give you sublists of n string checks based on your n-sized alphabet.

You can count the number of ‘true’ hits in the sublists at this point to determine how many letters exist.

---

<div class="post-metadata">

**Author:** ![Drbohlav](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/drbohlav/32/113004_2.png) [@Drbohlav](https://forum.dynamobim.com/u/Drbohlav)\
**Post date:** [April 9, 2021, 4:24pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/3 "2021-04-09T16:24:17Z")

</div>

I like this solution [Comparing two lists and getting the index of the "matching pairs" - #3 by AmolShah](https://forum.dynamobim.com/t/comparing-two-lists-and-getting-the-index-of-the-matching-pairs/60401/3)

---

<div class="post-metadata">

**Author:** ![brstewart](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@brstewart](https://forum.dynamobim.com/u/brstewart)\
**Post date:** [April 9, 2021, 4:33pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/4 "2021-04-09T16:33:22Z")

</div>

How long are the marks? if they vary project to project, you could ask for user input at the start, flag and that are more than 1 more or less than the user input. Or like create a default when a new project is created that the script can reference. Standard element IDs are like 6-7, right?

Could also just look for spaces.

If your users aren’t picky about seeing errors, you could try String.ToNumber, clean w/ preserve, filter

---

<div class="post-metadata">

**Author:** ![DaftPooch](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daftpooch/32/114199_2.png) [@DaftPooch](https://forum.dynamobim.com/u/DaftPooch)\
**Post date:** [April 9, 2021, 4:38pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/5 "2021-04-09T16:38:24Z")

</div>

well, that seems to do it. unreal, AmolShah, helped me with a previous question i had that i didn’t think this would apply to. i will make sure from now on to attempt anything i was taught before trying to reinvent the wheel.

 ![working filtering, question about selecting elements that are true](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/8/982fd108358257b8f2af3e41edf7c69cb1d6fd70.png)

Now if i want to be able to select said elements that are “true” in the project to make sure i do not overwrite them and give time for the designer to copy his “comment” elsewhere.

---

<div class="post-metadata">

**Author:** ![DaftPooch](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daftpooch/32/114199_2.png) [@DaftPooch](https://forum.dynamobim.com/u/DaftPooch)\
**Post date:** [April 9, 2021, 4:39pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/6 "2021-04-09T16:39:50Z")

</div>

This also worked, but the solution set by @Drbohlav seems to be more elegant and simpler. Thank you very much for your help and input.

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [April 9, 2021, 4:47pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/7 "2021-04-09T16:47:44Z")

</div>

@DaftPooch Try this:

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/7/6747b12b472726690dd13deecd212f46e6769b40.png)

I’ve removed your dependency on packages and also made sure that capital start letters are also covered in the check.

Also, you don’t need to type in a through z in the code block you can simply use  
“A”…“Z” or “a”…“z” or “A”…“z”

> [@DaftPooch](#):
>
> Now if i want to be able to select said elements that are “true”

Just use the same boolean mask to filter the elements as well.

---

<div class="post-metadata">

**Author:** ![DaftPooch](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daftpooch/32/114199_2.png) [@DaftPooch](https://forum.dynamobim.com/u/DaftPooch)\
**Post date:** [April 9, 2021, 4:50pm UTC](https://forum.dynamobim.com/t/search-for-letters-in-a-string/62741/8 "2021-04-09T16:50:47Z")

</div>

holy guacamole @AmolShah thank you for your prompt help!! that’s absolutely awesome. I will try this out right now!
