# Splitting string based on a given "pattern"

**URL:** <https://forum.dynamobim.com/t/splitting-string-based-on-a-given-pattern/31905>\
**Category:** Lists-Logic\
**Created:** [February 9, 2019, 4:58pm UTC](https://forum.dynamobim.com/t/splitting-string-based-on-a-given-pattern/31905 "2019-02-09T16:58:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_Flataker](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Benjamin\_Flataker](https://forum.dynamobim.com/u/Benjamin_Flataker)\
**Post date:** [February 9, 2019, 4:58pm UTC](https://forum.dynamobim.com/t/splitting-string-based-on-a-given-pattern/31905/1 "2019-02-09T16:58:04Z")

</div>

Hi,  
I’m having some trouble splitting string imported from a .kof file, this file is imported as a .txt file in Dynamo. Kof is frequently use by surveyors and contains coordinate information along with some metadata. The data in this kind of file is structured by their position in relation to each other. The points in this file is given by the code 05, and given in this structure: " 05 PPPPPPPPPP KKKKKKKK XXXXXXXX.XXX YYYYYYY.YYY ZZZZ.ZZZ Bk MMMMMMM"

The problems starts when some of the “points” in the file also contains some information in the KKKKKKKK- field and some doesn’t. See the attached screenshots from from the .kof file and Dynamo.

Is there any way Dynamo can use a given “pattern” to split a string and solve a problem like this?  
If so is also possible to place ex. “Null” when there isn’t any data in the KKKKKKK field?

 ![2019-02-09%2016_51_01-](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/5/9506382268fe094f188a53dad55f39279fd147c7.png)

 ![2019-02-09%2016_46_58-Dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/b/9bbe3cbd50f186d9113b589ac6ac686eed7dc9b7.png)

[S-17329HVL\_FM\_02\_Test.txt](https://forum.dynamobim.com/uploads/short-url/dl96EhZ5xYC7EVRixe3F2qJRZ2.txt) (1.7 KB)

[kof to point with information.dyn](https://forum.dynamobim.com/uploads/short-url/5OZ9Wd0kt4Wq5YBvIXUB4mPZaO3.dyn) (51.9 KB)

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 9, 2019, 6:08pm UTC](https://forum.dynamobim.com/t/splitting-string-based-on-a-given-pattern/31905/2 "2019-02-09T18:08:41Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/6/e6b6c3ecf53594748eb8de045d16899b7a7c4339.png)

---

<div class="post-metadata">

**Author:** ![Benjamin\_Flataker](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Benjamin\_Flataker](https://forum.dynamobim.com/u/Benjamin_Flataker)\
**Post date:** [February 10, 2019, 1:29pm UTC](https://forum.dynamobim.com/t/splitting-string-based-on-a-given-pattern/31905/3 "2019-02-10T13:29:48Z")

</div>

Thank you for you help, this kind of solves my problem!

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 10, 2019, 1:57pm UTC](https://forum.dynamobim.com/t/splitting-string-based-on-a-given-pattern/31905/4 "2019-02-10T13:57:30Z")

</div>

nicked it from @jostein_olsen

> [@Reading a select number of characters from a string](https://forum.dynamobim.com/t/reading-a-select-number-of-characters-from-a-string/5492):
>
> Hi I am trying to find easy way to read first 3 character from list, example: S01, S02, S02a, S03 I need : S01, S02, S02, S03 any node that read first n -characters?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [February 11, 2019, 4:10am UTC](https://forum.dynamobim.com/t/splitting-string-based-on-a-given-pattern/31905/5 "2019-02-11T04:10:49Z")

</div>

Splitting at the new lines and using a string.StartsWith to filter your strings that start with “-05 “ would likely also get you going in the right direction. Would also serve as a matching start for filtering other data as well.
