mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
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!
  }
}

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
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!


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Spaces matter:
Code:
if (

Last edited by Loki12583; 17/05/16 11:02 AM.
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
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!


I am SReject
My Stuff
Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
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!


Link Copied to Clipboard