I was exactly looking at that example, but how come the [h: id = strfind("this is a test", "(\\S+)\\s(\\S+)\\s*")] doesn't return 3 matches, rather than 2?
The third, which would actually be the second, should be "is a ", since it is a non-whitespace string followed by a whitespace, followed by another non-whitespace string, followed/not followed by another space.
Is it that when a part has been parsed, it looks for the next one, not caring for other parts that cross the already parsed one?
Regex and functions
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: Regex and functions
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
Re: Regex and functions
Personally, I hate that example. For one, it doesn't explain it. As to why there are only 2 matches is because once a part of the string matches you can't use any part of that string to make another match. So, match 1 is "this is " and match 2 is "a test". "is a " could be have been a match but is already a part of match 1.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Regex and functions
that example had been there for ages I just added the explanation. But feel free to rewrite it or even better add another.Personally, I hate that example.
And indeed matches cannot overlap
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: Regex and functions
On the matter of adding examples, is it possible to add to the wiki a "for real dummies" section of sort? I was considering trying to write up some of my learnings in a less technical way so that other people who aren't too familiar with various aspects of programming (such as regex) could get their heads on them a bit more easily. As well as further explanations for certain functions for which the wiki cuts it too short.
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
Re: Regex and functions
feel free to do so. If you don't have wiki access, pm craig to add you.Irrlicht wrote:On the matter of adding examples, is it possible to add to the wiki a "for real dummies" section of sort? I was considering trying to write up some of my learnings in a less technical way so that other people who aren't too familiar with various aspects of programming (such as regex) could get their heads on them a bit more easily. As well as further explanations for certain functions for which the wiki cuts it too short.
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: Regex and functions
Done, thanks.
And I also managed to get my macro to work as I wanted (quite a sweat, doing it).
Well, after aliasmask provided those bits of regex, I only had to add a tiny piece more... "(\\d+)" to get the numbers in XdY expressions and both "[+]+", "\\+" and "[-]+", "\\-" (since I divide the XdY expressions from all the +/-Z, I put all of these in another string, so I use those pieces of regex to change the occasional "+++" or "---" to a single "+" or "-").
But surely I got a way better understanding of regex and now it doesn't look anymore like censored bad words in Mickey Mouse's comics.
Thanks.
And I also managed to get my macro to work as I wanted (quite a sweat, doing it).
Well, after aliasmask provided those bits of regex, I only had to add a tiny piece more... "(\\d+)" to get the numbers in XdY expressions and both "[+]+", "\\+" and "[-]+", "\\-" (since I divide the XdY expressions from all the +/-Z, I put all of these in another string, so I use those pieces of regex to change the occasional "+++" or "---" to a single "+" or "-").
But surely I got a way better understanding of regex and now it doesn't look anymore like censored bad words in Mickey Mouse's comics.
Thanks.
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."