Raised This Month: $ Target: $400
 0% 

regexp_match problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
der_tabak
Junior Member
Join Date: Jan 2008
Old 06-26-2011 , 13:01   regexp_match problem
Reply With Quote #1

I have the following pattern:
Code:
"^"BANNED^" ^"is banned on ([^^:]*): (.*)^"$"
and I want to match for this lines:
Code:
"BANNED" "is banned on Betreutes Zocken: "idiot""
"BANNED" "is banned on Zechhalle Hamburg: VAC ban(s) on record"
"BANNED" "is banned on German Headquarter: Wallhack (D2AMX)"
"BANNED" "is banned on Bohramt: TA, FLAME, Gibt zu das er an hat..."
"BANNED" "is banned on Die wilden Siebziger: Import Bann.cfg"
"BANNED" "is banned on Psychiatrie: Autoban:  Other accounts VAC-Banned"
"BANNED" "is banned on Lost-Boy-Scouts: Autoban:  Other accounts VAC-Banned"
But I don't get any matches in AMX mod X, but the pattern from above ist working for me on regexpal.com
Code:
"BANNED" "is banned on ([^:]*): (.*)"$
I could and tried also to match with this pattern for example:
Code:
"^"BANNED^" ^"is banned on ([^^:]*): ([^^^"]*)^""
But the problem is, as you can see above the quotation marks can also occur in between the outside marks.

I'm also calling the regexp_match() function with the "m" flag.
der_tabak is offline
FoxueR
Senior Member
Join Date: Jun 2011
Old 06-26-2011 , 17:32   Re: regexp_match problem
Reply With Quote #2

In AMXX, ^ is the escape character. If you want to include it in a string, you have to use ^^, similar to how you would use \\ for \ in C.
__________________
¯\_(ツ)_/¯
FoxueR is offline
der_tabak
Junior Member
Join Date: Jan 2008
Old 06-26-2011 , 17:49   Re: regexp_match problem
Reply With Quote #3

Look at my first pattern, its already AMXX escaped, but it looks like the $ sign does not act like it should.

This is my unescaped regex pattern:
Code:
"BANNED" "is banned on ([^:]*): (.*)"$
It's working on regexpal.com properly with the lines in my first post.

AMXX escaped this looks like this:
Code:
"^"BANNED^" ^"is banned on ([^^:]*): (.*)^"$"
But I don't get any matches for lines like:
Code:
"BANNED" "is banned on Zechhalle Hamburg: VAC ban(s) on record"
"BANNED" "is banned on Betreutes Zocken: "idiot""

Last edited by der_tabak; 06-26-2011 at 17:52.
der_tabak is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-26-2011 , 18:43   Re: regexp_match problem
Reply With Quote #4

"BANNED" "is banned on ([^:]+): (.+)"

Works on all different test data you provided.

Code:
] regex_pattern ""BANNED" "is banned on ([^:]+): (.+)""
Pattern set to: "BANNED" "is banned on ([^:]+): (.+)"
] regex_test ""BANNED" "is banned on Betreutes Zocken: "idiot"""
3 matches
1. ""BANNED" "is banned on Betreutes Zocken: "idiot"""
2. "Betreutes Zocken"
3. ""idiot""
] regex_test ""BANNED" "is banned on Zechhalle Hamburg: VAC ban(s) on record""
3 matches
1. ""BANNED" "is banned on Zechhalle Hamburg: VAC ban(s) on record""
2. "Zechhalle Hamburg"
3. "VAC ban(s) on record"
] regex_test ""BANNED" "is banned on German Headquarter: Wallhack (D2AMX)""
3 matches
1. ""BANNED" "is banned on German Headquarter: Wallhack (D2AMX)""
2. "German Headquarter"
3. "Wallhack (D2AMX)"
] regex_test ""BANNED" "is banned on Bohramt: TA, FLAME, Gibt zu das er an hat...""
3 matches
1. ""BANNED" "is banned on Bohramt: TA, FLAME, Gibt zu das er an hat...""
2. "Bohramt"
3. "TA, FLAME, Gibt zu das er an hat..."
] regex_test ""BANNED" "is banned on Die wilden Siebziger: Import Bann.cfg""
3 matches
1. ""BANNED" "is banned on Die wilden Siebziger: Import Bann.cfg""
2. "Die wilden Siebziger"
3. "Import Bann.cfg"
] regex_test ""BANNED" "is banned on Psychiatrie: Autoban:  Other accounts VAC-Banned""
3 matches
1. ""BANNED" "is banned on Psychiatrie: Autoban:  Other accounts VAC-Banned""
2. "Psychiatrie"
3. "Autoban:  Other accounts VAC-Banned"
] regex_test ""BANNED" "is banned on Lost-Boy-Scouts: Autoban:  Other accounts VAC-Banned""
3 matches
1. ""BANNED" "is banned on Lost-Boy-Scouts: Autoban:  Other accounts VAC-Banned""
2. "Lost-Boy-Scouts"
3. "Autoban:  Other accounts VAC-Banned"
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
der_tabak
Junior Member
Join Date: Jan 2008
Old 06-26-2011 , 19:37   Re: regexp_match problem
Reply With Quote #5

Thanks, I solved the problem now by a bit trial and error, but I have forgotten to mention that my string looks more like this:
Code:
"BANNED" "is banned on Betreutes Zocken: Verdacht auf Cheat/ Multiacc."\r
"BANNED" "is banned on Puppets: Wallhack"\r
"BANNED" "is banned on Zechhalle Hamburg: VAC ban(s) on record"\r
So now this pattern works for me to get the first match:
Code:
"^"BANNED^" ^"is banned on ([^^:]+): ([^^^r]+)^"^r"
But my final question is, is there a possibility to get all matches from the entire string at once, or do I need to split the string on \r, and then try to match for every line?
der_tabak is offline
FoxueR
Senior Member
Join Date: Jun 2011
Old 06-26-2011 , 19:47   Re: regexp_match problem
Reply With Quote #6

Use something like this:

PHP Code:
new numerror[128], Regex:regex
regex 
regex_matchinput_str"^"BANNED^" ^"is banned on ([^^:]+): ([^^^r]+)^"^r"numerrorcharsmaxerror ) ) 

new 
substr[64]
for ( new 
inumi++ )
{
    
regex_substrregexisubstrcharsmaxsubstr ) )

    
// do something
}

regex_freeregex 
Of course, you'll need to add error handling and such.
__________________
¯\_(ツ)_/¯
FoxueR is offline
der_tabak
Junior Member
Join Date: Jan 2008
Old 06-26-2011 , 19:48   Re: regexp_match problem
Reply With Quote #7

Yes, I'm using this method, but this extracts only the matches of the first line, and not all the matches in my string, which contains multiple occurences(lines) of this pattern.
der_tabak is offline
FoxueR
Senior Member
Join Date: Jun 2011
Old 06-26-2011 , 19:50   Re: regexp_match problem
Reply With Quote #8

You'll probably have to break it up.
__________________
¯\_(ツ)_/¯
FoxueR is offline
der_tabak
Junior Member
Join Date: Jan 2008
Old 06-26-2011 , 20:08   Re: regexp_match problem
Reply With Quote #9

Ok, thanks.
der_tabak is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-27-2011 , 02:51   Re: regexp_match problem
Reply With Quote #10

It depends on how you get the data. If using file operations (fopen, fget, etc) then you would parse them line by line in the loop anyways and you do your regex there.
__________________
fysiks is online now
Reply


Thread Tools
Display Modes

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 23:28.


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