# String.Contains Node | 'Search for' modifications

**URL:** <https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612>\
**Category:** Revit\
**Tags:** revit, dynamo\
**Created:** [March 4, 2020, 9:13am UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612 "2020-03-04T09:13:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zalgirietis.minde](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zalgirietis.minde](https://forum.dynamobim.com/u/zalgirietis.minde)\
**Post date:** [March 4, 2020, 9:13am UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612/1 "2020-03-04T09:13:58Z")

</div>

Hello Dynamo Users,

I’m trying to filter out elements by size, removing everything what is less than 32.  
I faced a problem while trying to use the same script in a different project.

For example, if I want to remove DN15 pipe size by string contains, it will remove DN150 as well. I did a work around by adding space after DN15 and it worked in one project, because I had a list like:

25 mm - 25 mm  
.  
.  
.  
15 mm - 15 mm

But in this case I have different pipe fittings and the structure of the “size” parameter is something like this:

25-25  
.  
.  
.  
15-15

and my work around won’t work.  
Maybe someone can drop me any ideas how to make it suitable for not only 1 project individually?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/4/54f9371cc50a0e453ac18496fff05ea0671b89f4.png)  
Thanks.

---

<div class="post-metadata">

**Author:** ![3Pinter](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/3pinter/32/74327_2.png) [@3Pinter](https://forum.dynamobim.com/u/3Pinter)\
**Post date:** [March 4, 2020, 12:45pm UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612/2 "2020-03-04T12:45:19Z")

</div>

Why the usage of String.Contains? Perhaps you are better of using the “==” node?

---

<div class="post-metadata">

**Author:** ![zalgirietis.minde](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zalgirietis.minde](https://forum.dynamobim.com/u/zalgirietis.minde)\
**Post date:** [March 4, 2020, 1:30pm UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612/3 "2020-03-04T13:30:41Z")

</div>

I’m trying to get rid of the elements that has size 15 & 25. The problem is that the size parameter of different elements has different structure. See first code block. It might be even more complicated in different projects.

By using String.Contains node I’m able to filter out 15 & 25 values which is okay. But it filters out values like 150 and 250 as well.

I’m not sure if can do something with == in my case. It’s absolutely fine if I do have exact element parameter structure to compare with. But I don’t.

Unless I can try to filter values 150 & 250 back by adding some more nodes after. Is there a more smarter way to filter this out properly?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/2/521d3409bce0a9bf482dc6cbfa425d6fe54a170d.png)

---

<div class="post-metadata">

**Author:** ![3Pinter](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/3pinter/32/74327_2.png) [@3Pinter](https://forum.dynamobim.com/u/3Pinter)\
**Post date:** [March 4, 2020, 2:37pm UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612/4 "2020-03-04T14:37:35Z")

</div>

```
inputs = IN[0]
checks = IN[1]

output = []
for check in checks:
	for input in inputs:
		if check in input:
			output.append(input)
OUT = output

```

![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/c/ac126d7751bce3f9f988f2623bdaedf1c1936de5.png)

---

<div class="post-metadata">

**Author:** ![zalgirietis.minde](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zalgirietis.minde](https://forum.dynamobim.com/u/zalgirietis.minde)\
**Post date:** [March 4, 2020, 3:37pm UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612/5 "2020-03-04T15:37:09Z")

</div>

Sorry, I don’t think we are on the same page. But I agree, that the python script might be an option.

Find the node based version below. This is the result I’m after.

 ![Capture3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/0/f0e550281fbfe1b4ec3bb66bf59710bf38e99ae4.png)

Adding dyn file as well.  
[String\_Contains\_Test.dyn](https://forum.dynamobim.com/uploads/short-url/hkDpUy3zVFWyRTQDb2k2l6bZ1eb.dyn) (9.7 KB)

---

<div class="post-metadata">

**Author:** ![3Pinter](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/3pinter/32/74327_2.png) [@3Pinter](https://forum.dynamobim.com/u/3Pinter)\
**Post date:** [March 4, 2020, 3:49pm UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612/6 "2020-03-04T15:49:29Z")

</div>

Oh I see. I’d use regex.  
input\_digits[0] = first value of the list … since all your values in a string are always the same, I can use the first of the pair.  
(so “15” --\> input\_digits[0] is 15)  
(so “15 mm - 15 mm” --\> input\_digits is list 15, 15 … so input\_digits[0] is 15)

```
inputs = IN[0]
val = IN[1]

output = []
import re
for input in inputs:	
	input_digits = re.findall(r'\d+', input)
	if int(input_digits[0]) > val:
		output.append(input)
			
OUT = output

```

![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/8/98042dcd20bd7fa4bbb8e5816c0a09d4c5bd26e4.png)

---

<div class="post-metadata">

**Author:** ![zalgirietis.minde](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zalgirietis.minde](https://forum.dynamobim.com/u/zalgirietis.minde)\
**Post date:** [March 4, 2020, 3:57pm UTC](https://forum.dynamobim.com/t/string-contains-node-search-for-modifications/47612/7 "2020-03-04T15:57:58Z")

</div>

I would say that this is a solution. Thanks!

And I’m glad for this brief explanation as well. It’s always good to know what you are doing instead of copy pasting a code.

Cheers! Case is closed.
