Trying to break up a big blob of text by sentences but it always returns a blank for the list.
Tested it list so...
[h : theTest = "This is a test. Of the string to list. functionality"]
[h : theList = stringToList(theTest, ".")]
[r : "list = " + theList]
and what gets broadcast to the Chat window is just "list = ".
Is this a known issue? Or am I doing something really stupid here?
stringToList doesn't work with period as delimiter?
Moderators: dorpond, trevor, Azhrei
Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
Re: stringToList doesn't work with period as delimiter?
I didn't know this myself, but apparently the delimiter is regex, so...
Code: Select all
[h : theTest = "This is a test. Of the string to list. functionality"]
[h : theList = stringToList(theTest, "[.]")]
[r : "list = " + theList]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Cave Troll
- Posts: 28
- Joined: Tue Jul 21, 2020 7:50 pm
Re: stringToList doesn't work with period as delimiter?
Another possible way to say it is that the period is a character with a special meaning when you are searching for a delimiter, so you need to tell MapTool that you just want the period and not the special meaning. "[.]" works. Another possibility is to put a "\" in front of the period, so you are using "\." as your delimiter string. However, just to confuse things, there are times when the "\" also has a special meaning. Sometimes you have to put "\\." to get the appropriate search result.
The special meaning for "." is "match one character". The special meaning for "\" is "treat the next character as just a character with no special meaning".
There is a reason why people aren't fond of regular expressions ("regex"). They are powerful but sometimes painful to get right.
The special meaning for "." is "match one character". The special meaning for "\" is "treat the next character as just a character with no special meaning".
There is a reason why people aren't fond of regular expressions ("regex"). They are powerful but sometimes painful to get right.
-
- Kobold
- Posts: 1
- Joined: Fri Jan 15, 2021 1:20 am