Hello, i am trying to make code to split a folder name for instance "Sampletekk - ARP Solina" into two parts.
First part being stuff before " - " and second part being everything after it.
But i cannot make it find the: space dash space " - " part.
If i split from "-" this sign , it doesnt work because some folder names contain that on several occasions
How to get SplitStr to find this " - " Topic is solved
- JoeWinograd
- Posts: 2209
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: How to get SplitStr to find this " - " Topic is solved
Hi Ragnar,
I see that this is your first post here, so let me start with...Welcome Aboard!
Regards, Joe
I see that this is your first post here, so let me start with...Welcome Aboard!
The function is StrSplit, not SplitStr.Ragnar55 wrote:How to get SplitStr to find this " - "
I assume that you want the first part to be everything before the first " - ", and the second part to be everything after the first " - ", even if it has " - " strings in it. To achieve that, read the section called NaxParts in the StrSplit doc. With that in mind, here's some sample code:Ragnar55 wrote:it doesnt work because some folder names contain that on several occasions
Code: Select all
FolderName:="Sampletekk - ARP Solina - test - additional - hyphens"
Array:=StrSplit(FolderName," - ",,2) ; MaxParts=2
FirstPart:=Array[1]
SecondPart:=Array[2]
MsgBox % "1st=" FirstPart "`n2nd=" SecondPart
Re: How to get SplitStr to find this " - "
JoeWinograd wrote: ↑22 Apr 2024, 13:12Regards, JoeCode: Select all
FolderName:="Sampletekk - ARP Solina - test - additional - hyphens" Array:=StrSplit(FolderName," - ",,2) ; MaxParts=2 FirstPart:=Array[1] SecondPart:=Array[2] MsgBox % "1st=" FirstPart "`n2nd=" SecondPart
That works perfectly, thank you kind sir. This will end up helping more than just myself as i am trying to make this tool to help other people save time. Spent like 3 hours trying to get that part to work
- JoeWinograd
- Posts: 2209
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: How to get SplitStr to find this " - "
You're very welcome, Ragnar, I'm glad that it works for you. Regards, Joe