Zeroing out entries in the session log via a script

Fluxxdog

Active member
hee3: garfpuff, dargnabit. Yeah, that name regex should be
Code:
string regex_name = "([a-zA-Z][\\w\\d\\s]{0,28}[\\w\\d]{0,1})";
If length must be 3-30, shouldn't that be:
Code:
string regex_name = "([a-zA-Z][\\w\\d\\s]{1,28}[\\w\\d]{0,1})";
For that matter, why not:
Code:
string regex_name = "([a-zA-Z][\\w\\d\\s]+[\\w\\d])";
The ends will be only 1 character, so the center must be minimum 1 character, but why put a limit of 28 in if it's not strictly needed? Why not use "+"? This way we tell it, "Start with a letter, end with a word or digit, and have any words, digits, or whitespace in between."
Edit: As for the regex_id, commonly enough you'll find that href with people's name's, so name it regex_id_link. If you're working on parsing an html, you're gonna know the difference. At least you better or why would you be doing it in the first place? (Of course, that brings about the whole discussion of "assume complete stupidity" but if we did that, they wouldn't be building regexes to begin with. Meh.)
 
Last edited:

StDoodle

Minion
I didn't know there was a minimum number of chars. in a player name; I'm sure there is, but as far as I know it could be a single character.

I still have it messed up though; since everything that matches \d will match \w, the former is unnecessary. Also, the last character should be required once; I'm pretty sure you can't end a player name with a space (that has all sorts of potential for wonkiness, so I would hope it's not allowed by KoL). So the name matcher should be:
Code:
([a-zA-Z][\\w\\s]{0,28}\\w})
That still puts a floor of 2 characters on a name, but I doubt KoL allows single character names. Actually, I'm still not 100% on knowing what's allowed... anyone with more info, it would be appreciated. The limit of 30 characters is one of the few knows. Also, I like to limit as much as possible, because that avoids bugs in regexes that build with these (ie if this is not the entire matcher, but is PART of one).

Regarding ID's, 90% of the parsing I've done where I wanted to grab ID's was in clan logs, so I think of non-linky ID's as the "norm." I know this isn't true in general on KoL, but it's what I've become used to.

It seems the major disconnect is that I'm looking for a regex as precise as possible, so it can be flexible enough to be plugged into a matcher along with any possible combination of other strings / characters / saved regexes. You seem to be looking for a regex that is as simple as possible. Both are valid ways to go, IMO, but they tend to be better for different goals. My goal is not the "usual" programmer's goal; it's to make things as simple as possible for other ash scripters who aren't comfortable with regex.
 

Fluxxdog

Active member
Minimum characters is 3. Try to create one with 2 characters and it'll tell you otherwise. So {1,28} would be needed.
\w covers word characters which are alphanumeric and underscores, so yeah, the \d isn't needed. Nailed that one.
As far as the space on the end... don't know.
As far as simplicity, I'm thinking more of flexibility. If the standard was to change to allow more characters for whatever reason, the regex would be broken. Odd quirk of mine, I'll admit, but I've worked with so much experimental and beta software that it's habit.
 

StDoodle

Minion
It's kinda moot anyway; word boundaries are always going to be useful, if not necessary, to distinguish from other content that could otherwise match. But there's no "one way" that will always work, as sometimes those boundaries will / can be parts of html tags, sometimes something else.

Thanks for the heads-up on the 3-char. min; I've tried and tried, but failed to find out any documentation beyond KoL's own on the "30 character max." And there's so much I'd like to test, doing so by creating characters would be 11's.

I see your point of flexibility, but using greedy matching still seems like it would render most plug-and-play uses of the matcher unusable. Plus, the issue of allowing spaces in character names makes it very difficult to differentiate where a player's name ends and where other text begins; but again, that calls for specific boundary construction in the rest of the expression.

Honestly, I think we're getting far beyond what needs to be listed with any examples. Probably just need to make sure that we give a prominent "word boundaries are important, m'kay" disclaimer and call it good. ;)
 

Fluxxdog

Active member
Kingdom of Loathing character creation said:
Login name must be between 3 and 30 characters.
However, it is possible to create a 2 character name with (get this) two letter AND A SPACE. KoL then treats that space as nonexistent afterward. For an example, see the character Fu, which was created as "Fu ". The activation link even had his name as Fu+ indicated the space was recognized. In KoL though, everything will detect it as only 2 letters.

So 3 character minimum is likely not new, just that trailing spaces are cut.

BTW, that means that it would need to be {0,28} after all.
 
Top