Find string within another string?
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Find string within another string?
Any idea which function in Maptool can find matches for strings within another string? I saw strfind(), but it looks like it's for regular expressions. I'm looking for the equivalent to VBA's Instr() function, if it exists.
Re: Find string within another string?
strfind is the right function unless there is a certain format that string with in a string goes by that will allow something like listContains would work for. Can you give an example?
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Find string within another string?
I think what you are looking for is indexOf
Re: Find string within another string?
I've created this UDF in the BoT:
you can load the BoT (link in sig, function call is: bot_inStr(text, lookforstring) returns true or false (1 or 0)) or make a UDF yourself and copy paste that in. As you can see its regex by the way.
Spoiler
[H: '<!-- bot_inStr -->']
[H: '<!-- 0=Text, 1=string to look for in Text -->']
[r, if(arg(1)==""):""; getFindCount(strfind(arg(0), arg(1)))]
[H: '<!-- 0=Text, 1=string to look for in Text -->']
[r, if(arg(1)==""):""; getFindCount(strfind(arg(0), arg(1)))]
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Find string within another string?
Yep, indexOf looks exactly what I need. Thanks again!