 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
merc1286 Guest
|
Posted: Thu Mar 13, 2008 3:03 pm Post subject: Sending a space as part of the delimiter for StringSplit |
|
|
Hi, I am trying to use StringSplit to split a string wherever " - " is found (a space, then a dash, then another space). I have tried a number of things, but they either don't work or automatically trim off the spaces and just split on any - whether or not it is surrounded by spaces. I have tried the following:
StringSplit, x_array, x, -
StringSplit, x_array, x, " - "
StringSplit, x_array, x, {Space}-{Space}
But none of them worked. The 3rd one actually seemed to split it at the first occurrence of the letter S.
Any ideas? thanks. |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Thu Mar 13, 2008 3:12 pm Post subject: |
|
|
| Code: | StringSplit, x_array, x, % " - " ; expression-type coding
StringSplit, x_array, x, {A_Space}-{A_Space} ; traditional-type coding |
|
|
| Back to top |
|
 |
merc1286 Guest
|
Posted: Thu Mar 13, 2008 3:39 pm Post subject: |
|
|
Hi, thanks for trying, but neither of those worked. The first one delimited it at the first occurrence of a -, even one without any spaces around it, and the other delimited it at the first occurrence of the letter A. Any other thoughts?
Thanks! |
|
| Back to top |
|
 |
merc1286 Guest
|
Posted: Thu Mar 13, 2008 4:53 pm Post subject: |
|
|
| Actually, further investigation has shown me that what it's doing is, even when I have " - " specified as the delimiter, it appears to be treating that as 3 separate delimiters (a space, a dash, and another space), and then searching for the first occurrence of any of those. How can I tell it to search for the entire string? |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 39
|
Posted: Fri Mar 14, 2008 2:22 am Post subject: |
|
|
| merc1286 wrote: | | How can I tell it to search for the entire string? |
From AHK help: "To use a string as a delimiter rather than a character, first use StringReplace to replace all occurrences of the string with a single character that is never used literally in the text." |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|