Raised This Month: $159 Target: $400
 39% 

Solved Regex Argument Type Mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: US
Old 05-03-2017 , 19:31   Regex Argument Type Mismatch
Reply With Quote #1

So I have this

PHP Code:
Regex CountDown;
CountDown.Regex("/{CountDown:([1-9]+)}/"PCRE_CASELESSRegexErrsizeof RegexErrCountDownError); 
And I'm getting

PHP Code:
error 035argument type mismatch (argument 1
Not sure where I went wrong

Last edited by RumbleFrog; 05-04-2017 at 21:20.
RumbleFrog is online now
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: US
Old 05-03-2017 , 20:28   Re: Regex Argument Type Mismatch
Reply With Quote #2

Also, how do I get the entire matching string instead of substrings? Similar to how PHP's preg_match work.
RumbleFrog is online now
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 05-03-2017 , 22:29   Re: Regex Argument Type Mismatch
Reply With Quote #3

PHP Code:
Regex CountDown = new Regex("/{CountDown:([1-9]+)}/"PCRE_CASELESSRegexErrsizeof RegexErrCountDownError);
//do something
delete CountDown
Not sure what you mean by the 2nd question.
__________________

Last edited by Chaosxk; 05-03-2017 at 22:29.
Chaosxk is offline
BAILOPAN
Join Date: Jan 2004
Old 05-03-2017 , 23:11   Re: Regex Argument Type Mismatch
Reply With Quote #4

Chaosxk is correct - sorry, the error message was totally unhelpful there. Will be fixed: https://github.com/alliedmodders/sourcepawn/pull/111
__________________
egg
BAILOPAN is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: US
Old 05-03-2017 , 23:35   Re: Regex Argument Type Mismatch
Reply With Quote #5

Quote:
Originally Posted by Chaosxk View Post
PHP Code:
Regex CountDown = new Regex("/{CountDown:([1-9]+)}/"PCRE_CASELESSRegexErrsizeof RegexErrCountDownError);
//do something
delete CountDown
Not sure what you mean by the 2nd question.
Thanks. My second question was that in PHP, the match's 0th index is the entire substring that matches the pattern. But in GetSubString, 0th is already the first regex capture group

http://php.net/manual/en/function.preg-match.php

Quote:
If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.
RumbleFrog is online now
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 05-04-2017 , 03:47   Re: Regex Argument Type Mismatch
Reply With Quote #6

You could use Match to get the count of substrings and loop through with GetSubString and concat the substring to another string.
__________________
Chaosxk is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-04-2017 , 04:29   Re: Regex Argument Type Mismatch
Reply With Quote #7

Your best option is to stick a capture group around the whole pattern.
__________________
asherkin is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: US
Old 05-04-2017 , 21:20   Re: Regex Argument Type Mismatch
Reply With Quote #8

Quote:
Originally Posted by asherkin View Post
Your best option is to stick a capture group around the whole pattern.
Thanks! This completes it.
RumbleFrog 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 02:25.


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