PDA

View Full Version : Problem with "Split Source String at First Occurrence of Search String"



NewsArchive
04-27-2009, 12:56 AM
In SB6 2560:

Given the string '(text1),(text2)' split on first occurrence of '('
returns 'text2)' as the portion after the first occurrence.

I consider that to be the portion after the 2nd occurrence of the source
string.

My workaround is to prefix a character other than '(' to the source.
However, I consider this a bug.

--
Phil Carroll
http://www.enablingsimplicity.com

NewsArchive
04-27-2009, 12:56 AM
Hi Friedrich,

I would like to see an option:
- Split BEFORE the first occurence
- Split AFTER the first occurence

Markus

NewsArchive
04-27-2009, 12:57 AM
Phil,

> I consider that to be the portion after the 2nd occurrence of the source
> string.

Yes, you are right. The correct value should be 'text1),(text2)' in this
case.

Thank you for bringing this to my attention.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
04-28-2009, 01:05 AM
Markus,

> I would like to see an option:
> - Split BEFORE the first occurence
> - Split AFTER the first occurence

Split already does that. You have four arguments (not in this order):
S1) The string to split
S2) The search argument
v1) a variable to receive the part before the search argument
v2) a variable to receive the part after the search argument

Given:
S1 = 'abcdefgh'
S2 = 'de'

After the split:
v1 = 'abc'
S2 = 'de'
v2 = 'fgh'

With repeated use of split, you can parse just about anything.

--
Phil Carroll
http://www.enablingsimplicity.com