Raised This Month: $ Target: $400
 0% 

[HELP] I have a problem with regex in my plugin.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-05-2009 , 08:48   Re: [HELP] I have a problem with regex in my plugin.
Reply With Quote #5

Quote:
Originally Posted by unSeen View Post
What you mean
I couldn't understand.
Why I need to use [][] array? it will be like new array[32][1] and it's looks pretty stupid O_o.
Can you please explain you'r self?
A string is an array of characters.
Therefore an array of strings is an array of arrays.
Therefore it is a two dimensional array.

Line 21: new g_arrszWords[MAX_WORDS + WORDS_OFFSET][LEN_WORDS+1]
Line 44: g_arrszWords[i][0] = NULL
Line 84: formatex(g_arrszWords[nCount], LEN_WORDS, fData)
Line 141: if (g_arrszWords[j][0] == NULL) {

Line 134: I'd think it would be more efficient to loop over only nCount and not MAX_WORDS everytime. You could get rid of anything with NULL.


Quote:
Originally Posted by unSeen View Post
I read in the link wich you gave me (this) and nothing is written there about Sensivity case.
also in the AMXx.org functions -> regex_match there is nothing about Sensivity Case.
That link was just to show you how they suggest you use regex. The case insensitivity flag is in the comment in regex.inc:

Code:
/**
 * Matches a string against a regular expression pattern.
 *
 * @note                If you intend on using the same regular expression pattern
 *                        multiple times, consider using regex_compile and regex_match_c 
 *                        instead of making this function reparse the expression each time.
 *
 * @param string       The string to check.
 * @param pattern      The regular expression pattern.
 * @param ret          Error code, or result state of the match.
 * @param error        Error message, if applicable.
 * @param maxLen       Maximum length of the error buffer.
 * @param flags        General flags for the regular expression.
 *                        i = Ignore case
 *                        m = Multilines (affects ^ and $ so that they match 
 *                            the start/end of a line rather than matching the 
 *                            start/end of the string).
 *                        s = Single line (affects . so that it matches any character, 
 *                            even new line characters).
 *                        x = Pattern extension (ignore whitespace and # comments).
 *
 * @return                -2 = Matching error (error code is stored in ret)
 *                        -1 = Error in pattern (error message and offset # in error and ret)
 *                         0 = No match.
 *                        >1 = Handle for getting more information (via regex_substr)
 *
 * @note                Flags only exist in amxmodx 1.8 and later.
 * @note                You should free the returned handle (with regex_free())
 *                        when you are done extracting all of the substrings.
 */
native Regex:regex_match(const string[], const pattern[], &ret, error[], maxLen, const flags[] = "");


Quote:
Originally Posted by unSeen View Post
btw, In every language regex pattern is between two "/" and after the second one comes the header flags, 'i' is the one that tells the regex to ignore sensivity case.
Not true. They don't use delimiters in the example and I've never used them when using POSIX ERE.

Maybe it will work after you get strings in your array. But I don't know why they would add that flag if you could just use what you describe there.
__________________
fysiks is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode