It is currently Tue May 30, 2017 4:03 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Split doesn't work for me
Unread postPosted: Wed Mar 15, 2017 5:45 am 
Offline
User avatar

Joined: Thu May 16, 2013 2:58 pm
Posts: 178
This example didn't work for me:

string$ = "a:b:c:d"
delimiter$ = ":"
SPLIT result$[], string$, delimiter$
ARRAY.LENGTH length, result$[]
FOR i = 1 TO length
PRINT result$[i] + " ";
NEXT i
PRINT ""

_________________
My Apps on the Google Play Store.

Please click on the Banner below, thank you!
Image


Top
 Profile  
 
 Post subject: Re: Split doesn't work for me
Unread postPosted: Wed Mar 15, 2017 8:14 am 
Offline

Joined: Sat May 14, 2011 7:43 am
Posts: 358
Location: South Africa, UK & US (Florida)
It appeared to work perfectly for me! What was it doing wrong for you?

Peter


Top
 Profile  
 
 Post subject: Re: Split doesn't work for me
Unread postPosted: Wed Mar 15, 2017 11:57 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Hi dtrieb

Seems to run ok ;)

Regards Roy

Attachment:
abcd.PNG
abcd.PNG [ 19.15 KiB | Viewed 412 times ]


Top
 Profile  
 
 Post subject: Re: Split doesn't work for me
Unread postPosted: Wed Mar 15, 2017 1:48 pm 
Offline

Joined: Tue Dec 04, 2012 10:50 am
Posts: 656
Location: UK
[email protected] wrote:
It appeared to work perfectly for me! What was it doing wrong for you?

Peter

Yes, it's always better to say what does happen rather than what does not!

Mike.


Top
 Profile  
 
 Post subject: Re: Split doesn't work for me
Unread postPosted: Fri Mar 17, 2017 4:38 am 
Offline
User avatar

Joined: Thu May 16, 2013 2:58 pm
Posts: 178
Okay now it works ... Crazy!

But I need another help.
That my Code:

Code:
komplett$ = "[email protected]+492•+491•07.04.1982"
trenner$ = "•"

TEXT.INPUT komplett$,komplett$,"Kompletter Text:"
SPLIT string$[], komplett$,trenner$
ARRAY.LENGTH length, string$[]

INPUT "Vorname:",string$[1],string$[1]
INPUT "Nachname:",string$[2],string$[2]
INPUT "Straße:",string$[3],string$[3]
INPUT "Ort:",string$[4],string$[4]
INPUT "EMail:",string$[5],string$[5]
INPUT "Festnetz:",string$[6],string$[6]
INPUT "Mobil:",string$[7],string$[7]
INPUT "Geburtstag:",string$[8],string$[8]


1) First I would like to change the dot • to | as delimiter but that throw an error.
2) What can I do if between the delimiter is nothing like "Daniel•Sch•Str•ort••+492•+491•07.04.1982"

It didn't split right then.

Thanks for your answers!

_________________
My Apps on the Google Play Store.

Please click on the Banner below, thank you!
Image


Top
 Profile  
 
 Post subject: Re: Split doesn't work for me
Unread postPosted: Tue Mar 21, 2017 12:10 am 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2797
Location: Colorado, U.S.
1) The search string in Split (your trenner$) is a regular expression. In a regular expression, "|" means "or". You are telling Split to split on "nothing or nothing". There is nothing between any two characters, so it splits every character into a separate array element.

To fix it, you need the regular expression parser to see "\|" -- the backslash "escapes" the bar so it is just a character, not the or operator. However, to get the "\" through the BASIC! parser, you have to escape it, too: "\\|".
One '\' for the BASIC! parser and one more for the regular expression parser, then you can use "|" as a delimiter:
Code:
komplett$ = "[email protected]|+492|+491|07.04.1982"
trenner$ = "\\|"

As it says in the manual:
De Re Basic! wrote:
The <test_sexp> is actually a Regular Expression. If you are not getting the results that you expect from the <test_sexp> then you should examine the rules for Regular Expressions".

2) The search string is a regular expression. You just have to find a regular expression that matches everything you want to split on.
If you say you want to split on "|", then two delimiters together "||" each match the search string, and the nothing between them becomes an empty array element.
But if you tell it to split any time it finds one or more "|", then "|" is a single delimiter, and "||" is a single delimiter, and "|||" is a single delimiter, and so on.

In a regular expression "+" means "one or more":
Code:
komplett$="Daniel•Sch•Str•ort••+492•+491•07.04.1982"
trenner$="•+"
komplett$="Daniel|Sch|Str|ort||+492|+491|07.04.1982"
trenner$="\\|+"

- Marc


Top
 Profile  
 
 Post subject: Re: Split doesn't work for me
Unread postPosted: Wed Mar 22, 2017 5:07 am 
Offline
User avatar

Joined: Thu May 16, 2013 2:58 pm
Posts: 178
Thanks Marc,

sometimes I read the manual, sometimes not. I this case not. (A stupid mistake)

Now I'm​ happy and can go on ... Thank you again!

_________________
My Apps on the Google Play Store.

Please click on the Banner below, thank you!
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred