mIRC Homepage
Posted By: Trahanqc Compare two strings not working - 17/05/16 05:31 AM
Hi, I'm trying to compare two strings using a regex but even with basic regex it does not seems to work when I put it in an If statement.

Code:
on *:text:*:#: {
  ; Returns 1 => This is normal
  msg $chan $regex(test,test)

  ; Returns 0 => This is normal
  msg $chan $regex(test,hi)

  ; Echo Passed! in the channel even if it's false
  if($regex(test,hi)) {
    msg $chan Passed!
  }
}
Posted By: westor Re: Compare two strings not working - 17/05/16 07:18 AM
I recommend you to read this article that it's about the mIRC Regex before starting coding using regex, it's the best on the market!
Posted By: Loki12583 Re: Compare two strings not working - 17/05/16 11:01 AM
Spaces matter:
Code:
if (
Posted By: FroggieDaFrog Re: Compare two strings not working - 17/05/16 11:09 AM
loki is correct, spaces matter

Code:
/if($regex(test,hi))

The above is seen as a literal command of: "if($regex(test,hi))". If you check your status window you'll probably see an error along the lines of "unknown command". That is because any commands mIRC does not recognize get sent to the IRC server

Without the correct spacing, your code is doing
Code:
;; calls the command "if(regex(test,hi))"
;; where the first parameter is "{"
/if($regex(test,hi)) {

;; since the above isn't seen as an
;; if-then-else block the /msg is at the
;; same processing level as the above
;; statement and gets processed aswell
msg $chan Passed!
Posted By: Trahanqc Re: Compare two strings not working - 17/05/16 03:15 PM
Originally Posted By: Loki12583
Spaces matter:
Code:
if (


Omg it has been a long time since I coded with mIrc and I totally forgot that! Thanks!
© mIRC Discussion Forums