How can I split string
“994 - CUSTODY ACC. VLASNICKI 5409940000000054440101996 - CUSTODY ACC. DUZNICKI 5409960000000004940101”
into substrings by length 52? It has to be dynamic spliting becouse string is not always the same.
Could you elaborate your question?
Your question is confusing. Is it 52 or is it dynamic? What is the result you want out of the example string? What do other example strings look like?
str=your string
substr1=str.Substring(0,51)
substr2=str.Substring(52,str.length)
If this is what you’re looking for.
It will throw error. It should be like this:
str=your string
substr1=str.Substring(0,52)
substr2=str.Substring(52, str.Length-(str.Substring(0,52).Length))
That doesn’t make any sense. str.Substring(0,52).Length will always be 52 since you literally told it to take 52 characters.
And I’ve never had a Substring command throw an error if the length specified is longer than what is available.
Getting the length of Substring(0,52) makes no sense. The length is 52. You could just hard code the 52. str.Substrig(0,52).Length will always be 52.
And the length property is unnecessary.
It is much better and and convenient @postwick
Well, the most convenient is not to use substring at all.
Although this assumes the string is always the same total length. If that’s not the case, then for the first one you want to use Left, and for the second one you want to use Substring.