slushpuppy
2012-05-29 10:14:03

Output:
['Fr41m']
2012-05-29 10:14:03

2012-05-29 10:21:08
2012-05-29 10:52:51
2012-05-29 10:53:45
From: Kyle Undefined
More information will be helpful.
2012-05-29 11:47:01
From: Shay
More information about giving more information would be helpful ;)
@OP, are you trying to make a caller for SW?
writeln(ChatBoxTextArray(COLOROFFC)));
2012-05-29 13:42:06

2012-05-29 14:08:48
{$I SRL/SRL.Simba}
Function IsChatBoxTextEx(RegExpr: String; Colour: Integer): Boolean;
var
I, L: Integer;
TSA: TStringArray;
begin
TSA:= ChatBoxTextArray(Colour);
L:= High(TSA);
For I:= 0 To L Do
if ExecRegExpr(RegExpr, TSA[I]) then
begin
Result:= True;
break;
end;
end;
begin
//DO NOT put spaces in the regex. Spaces are denoted by "\s" Non-white-space is denoted by "\S"
//Brackets aren't allowed unless escaped by a backslash and finally the * means to repeat the previous expression 0 or more times.
writeln(IsChatBoxTextEx('(Fr4(\s)*1m)', clBlack));
//The above Regex is equivalent to '(Fr4 1m)|(Fr41m)|(Fr4 1m)|(Fr4 1m)'... etc.. keeps going for an infinite amount of spaces.
end.
2012-05-29 23:19:36
From: Brandon
This isn't that big a bug and it's easily solved. The bitmap for space doesn't fit there. So how to solve it?
{$I SRL/SRL.Simba}
Function IsChatBoxTextEx(RegExpr: String; Colour: Integer): Boolean;
var
I, L: Integer;
TSA: TStringArray;
begin
TSA:= ChatBoxTextArray(Colour);
L:= High(TSA);
For I:= 0 To L Do
if ExecRegExpr(RegExpr, TSA[I]) then
begin
Result:= True;
break;
end;
end;
begin
//DO NOT put spaces in the regex. Spaces are denoted by "\s" Non-white-space is denoted by "\S"
//Brackets aren't allowed unless escaped by a backslash and finally the * means to repeat the previous expression 0 or more times.
writeln(IsChatBoxTextEx('(Fr4(\s)*1m)', clBlack));
//The above Regex is equivalent to '(Fr4 1m)|(Fr41m)|(Fr4 1m)|(Fr4 1m)'... etc.. keeps going for an infinite amount of spaces.
end.
2012-05-29 23:31:02
From: slushpuppy
The biggest problem with that so called 'solution' is that people have to hardcode every single mismatch that occurs…
'[A-Za-z0-9_]' // Matches A-z, 0-9 and underscore..
'^[A-Za-z]' // Matches A-z only if at the beginning of a line..
'[0-9]*$' //Matches 0-9 any amount of times AND matches the end of a line aka linefeed.
2012-05-30 04:58:52
From: Brandon
A regex is not hardcoding.. The way your going about it is literally hardcoding. The fact that it doesn't find your exact and specific text due to a space in it, is hardcoding.
Regular Expressions are otherwise known as pattern matching. It matches a specified pattern.
For an example of a pattern than matches a TPointArray, see here: http://villavu.com/forum/showpost.php?p=1019210&postcount=3
The function is called STRToTPA. It's not hardcoded because you can enter any TPA and it will work. hardcoding is where the values must be very specific.
What I gave you is the ultimate solution. A Regular Expression to match any pattern you like. Of course you'd write your own expressions.
Some useful ones:
'[A-Za-z0-9_]' // Matches A-z, 0-9 and underscore..
'^[A-Za-z]' // Matches A-z only if at the beginning of a line..
'[0-9]*$' //Matches 0-9 any amount of times AND matches the end of a line aka linefeed.
Those are just some examples. Of course there are as many patterns as the mind can think of.
Perhaps you can describe exactly what you want and I can provide a close if not exact solution..
2012-05-30 08:46:56
2012-05-30 08:51:50
From: Sir R. M8gic1an
If the issue is the spaces, just TrimSpaces() both on what you're looking for and on what the GetText function returns. Voila.
~RM
2012-05-30 09:27:42
From: Dgby714
I'm pretty sure what he is looking for is dynamic and he needs to know specifically what was said.
That aside, You could use another delimiter.