# Split(x,x)

**URL:** <https://ifnotnil.com/t/split-x-x/601>\
**Category:** General Programming\
**Created:** [9 June 2020 22:55 UTC](https://ifnotnil.com/t/split-x-x/601 "2020-06-09T22:55:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![doj](https://ifnotnil.com/user_avatar/ifnotnil.com/doj/32/530_2.png) [@doj](https://ifnotnil.com/u/doj)\
**Post date:** [9 June 2020 22:55 UTC](https://ifnotnil.com/t/split-x-x/601/1 "2020-06-09T22:55:50Z")

</div>

Hi All,

Mac Desktop, API1 only, 19r1.

I have a large (to me at least) up to 20Mb text file to search through for several differing patterns of data.

it is a file of data generated by one of my Amateur Radio programs and it includes callsign and location (public QRA data published by the user with the expectation it is used by anyone to determine an approximate location).

This file is updated every 60 seconds and is intended by the app to be parsed by third parties to add features to the application use.

I am using Split(x,x) which works ok and surprized me how quickly it can split a 10Mb file into an array of 15 elements following an EndOfLine.

But I had thought it might be simple to add to the Split(x,x) a secondary hack or two to tweak it to remove more of the unwanted stuff in a single pass.

The question is, what is the raw code for Split(x,x) or anything that anyone has which has a similar function, or is there different way to remove expected data from a string of data that is not a built in Xojo method and will at least not be any slower than Xojo inbuilt stuff might be.

I am not wanting super speed like less than 100ms to parse out all the stuff I want, but I might like to keep it below 10 seconds on its first pass at boot up, subsequent passes will use the time stamp generated by the file (at 1 minute intervals) to work on only a very tiny amount of data, maybe 2k each time.

Thanks for looking.

Mark

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [9 June 2020 23:07 UTC](https://ifnotnil.com/t/split-x-x/601/2 "2020-06-09T23:07:36Z")

</div>

Guess it depends on what it is you need to do  
Replace and ReplaceAll can be useful - but on huge strings they take in one, process it and produce another so at one point you have the “old” data and “new” data in memory at the same time  
That _may_, or may not, be an issue

---

<div class="post-metadata">

**Author:** ![doj](https://ifnotnil.com/user_avatar/ifnotnil.com/doj/32/530_2.png) [@doj](https://ifnotnil.com/u/doj)\
**Post date:** [9 June 2020 23:45 UTC](https://ifnotnil.com/t/split-x-x/601/3 "2020-06-09T23:45:20Z")

</div>

I am not thinking replace is what I would like to do, remove is more like it.

in looking at replace I noticed trim which might help in one of the instances I have which is great.

trying to explain in a note what the data needs to be parsed into and from what, is a lot more complex than I am sure any one needs to see.

trim will now get a testing out and I will come back if there is anything I might need to optimize.

Thanks Norman.

---

<div class="post-metadata">

**Author:** ![jmadren](https://ifnotnil.com/user_avatar/ifnotnil.com/jmadren/32/65_2.png) [@jmadren](https://ifnotnil.com/u/jmadren)\
**Post date:** [10 June 2020 01:40 UTC](https://ifnotnil.com/t/split-x-x/601/4 "2020-06-10T01:40:00Z")

</div>

> [@doj](#):
>
> I am not thinking replace is what I would like to do, remove is more like it.

Replace will remove if you replace with an empty string.

For very powerful (but super complicated) there’s the RegEx stuff.

---

<div class="post-metadata">

**Author:** ![HMARROQUINC](https://ifnotnil.com/user_avatar/ifnotnil.com/hmarroquinc/32/256_2.png) [@HMARROQUINC](https://ifnotnil.com/u/HMARROQUINC)\
**Post date:** [10 June 2020 01:54 UTC](https://ifnotnil.com/t/split-x-x/601/5 "2020-06-10T01:54:27Z")

</div>

I was going to mention RegEx.Replace and then I remembered how I hate Regex LOL. I will be working on unpdating an app I worked on some years ago and I need to work with some large .edi files, I re-read the RegEx docs and decided I’m keeping my Split() solution 🙂

---

<div class="post-metadata">

**Author:** ![doj](https://ifnotnil.com/user_avatar/ifnotnil.com/doj/32/530_2.png) [@doj](https://ifnotnil.com/u/doj)\
**Post date:** [10 June 2020 02:59 UTC](https://ifnotnil.com/t/split-x-x/601/6 "2020-06-10T02:59:33Z")

</div>

Thanks both,  
still to get to test replace, if the empty string removes rather than replace with an empty string it will work fine.

I also forgot to mention regex is not something I want to spend time learning, it seems to the uninitiated (me) like linux command line without any of the charm or well written instructions that linux has.

I am glad Hector that I am not the only person to want to persevere with the less complicated inbuilt functions!  
BUT we are both fools to dismiss the absolute power of RegEx, I know I just can not be bothered to study it, my bad for sure.

---

<div class="post-metadata">

**Author:** ![HMARROQUINC](https://ifnotnil.com/user_avatar/ifnotnil.com/hmarroquinc/32/256_2.png) [@HMARROQUINC](https://ifnotnil.com/u/HMARROQUINC)\
**Post date:** [10 June 2020 03:37 UTC](https://ifnotnil.com/t/split-x-x/601/7 "2020-06-10T03:37:59Z")

</div>

True. In fact RegEx is in my list of things I want to learn in the next couple of months. I don’t like it but I’m well aware of it’s power.

I’ve been following this guy’s youtube channel for a while and I like the way he explains things:

[https://www.youtube.com/watch?v=7DG3kCDx53c](https://www.youtube.com/watch?v=7DG3kCDx53c)

I guess I’ll watch the series on RegEx a couple of times, read about it and then practice practice practice. Perhaps I’ll even manage to not hate it in the future.

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [10 June 2020 03:55 UTC](https://ifnotnil.com/t/split-x-x/601/8 "2020-06-10T03:55:29Z")

</div>

> [@doj](#):
>
> I also forgot to mention regex is not something I want to spend time learning, it seems to the uninitiated (me) like linux command line without any of the charm or well written instructions that linux has.

Hahahahahahahahahahahahahaha … have to admit this is the best line of humor I’ve seen in a while 🙂

---

<div class="post-metadata">

**Author:** ![Clothears](https://ifnotnil.com/letter_avatar_proxy/v4/letter/c/90db22/32.png) [@Clothears](https://ifnotnil.com/u/Clothears)\
**Post date:** [10 June 2020 11:02 UTC](https://ifnotnil.com/t/split-x-x/601/9 "2020-06-10T11:02:52Z")

</div>

regex, Perl, TECO - all write only.

As somebody said: there’s no obfuscated Perl contest because there’s no point.

Same applies to the others I mentioned.

---

<div class="post-metadata">

**Author:** ![doj](https://ifnotnil.com/user_avatar/ifnotnil.com/doj/32/530_2.png) [@doj](https://ifnotnil.com/u/doj)\
**Post date:** [10 June 2020 12:14 UTC](https://ifnotnil.com/t/split-x-x/601/11 "2020-06-10T12:14:58Z")

</div>

I thank you Norman!

---

<div class="post-metadata">

**Author:** ![doj](https://ifnotnil.com/user_avatar/ifnotnil.com/doj/32/530_2.png) [@doj](https://ifnotnil.com/u/doj)\
**Post date:** [11 June 2020 02:17 UTC](https://ifnotnil.com/t/split-x-x/601/12 "2020-06-11T02:17:53Z")

</div>

to get back to one of the original questions, is there any code in Xojo than anyone has that mimics the Split(x,x) function.  
I wonder how this function, or others such as Left, Right etc are formulated, is it a C function of some sort or what? (forgive my utter ignorance of how my random typing in the IDE ends up as an application)

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [11 June 2020 03:42 UTC](https://ifnotnil.com/t/split-x-x/601/13 "2020-06-11T03:42:05Z")

</div>

> [@doj](#):
>
> I wonder how this function, or others such as Left, Right etc are formulated, is it a C function of some sort or what? (forgive my utter ignorance of how my random typing in the IDE ends up as an application)

It is part of the framework that Xojo provides that is written in C++/Objective-C (depending on platform the mix varies)
