About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

 Related 
Contents
Comparison
  %begins
  %ends
  %len
  %match
  %pos
  Comparison
Function Reference
  %abs
  %additem
  %addkey
  %alarm
  %alias
  %ansi
  %array
  %arrget
  %arrhigh
  %arrset
  %ascii
  %average
  %begins
  %bitand
  %bitnot
  %bitor
  %bitset
  %bitshift
  %bittest
  %bitxor
  %btncol
  %btnenable
  %btnimage
  %case
  %char
  %charcomment
  %charnotes
  %class
  %clip
  %color
  %colorname
  %colorsyntax
  %comactive
  %comcreate
  %comget
  %comset
  %concat
  %copy
  %count
  %countlist
  %crtonl
  %db
  %dbget
  %dbitems
  %dbkey
  %dbkeys
  %dblist
  %dbmax
  %dbmin
  %dbvalues
  %dde
  %ddeclose
  %ddemacro
  %ddeopen
  %ddepoke
  %defined
  %delete
  %delitem
  %delkey
  %delnitem
  %destroom
  %dice
  %diceavg
  %dicedev
  %dicemax
  %dicemin
  %doorname
  %dups
  %ends
  %eval
  %exec
  %exp
  %expand
  %expanddb
  %expandlist
  %filesize
  %find
  %float
  %format
  %getglobal
  %grep
  %gsl
  %handle
  %hexcolor
  %hexnum
  %hexstr
  %htmldecode
  %htmlencode
  %iconstate
  %if
  %insert
  %int
  %inwalk
  %isfloat
  %iskey
  %ismember
  %isnumber
  %isvalue
  %item
  %json
  %lastdir
  %left
  %leftback
  %len
  %line
  %list
  %literal
  %look
  %lower
  %mapfilter
  %maplocked
  %mapquery
  %mapvnum
  %match
  %max
  %mcp
  %min
  %mod
  %mss
  %nextdir
  %nltocr
  %norm
  %null
  %number
  %numbuttons
  %numitems
  %numkeys
  %numparam
  %numrec
  %numrooms
  %numwords
  %numzones
  %packages
  %param
  %params
  %parsemode
  %parsenumbers
  %pat
  %pathcompress
  %pathexpand
  %pathfrom
  %pathreverse
  %pick
  %pop
  %portal
  %portalenabled
  %pos
  %pref
  %priority
  %prompt
  %proper
  %push
  %query
  %quote
  %random
  %read
  %ref
  %regex
  %remove
  %repeat
  %replace
  %replaceitem
  %reversedir
  %rgb
  %right
  %rightback
  %roomcol
  %roomcom
  %roomcontents
  %roomcost
  %roomdesc
  %roomexit
  %roomflags
  %roomid
  %roomint
  %roomkey
  %roomkind
  %roomlink
  %roomload
  %roommode
  %roomname
  %roomnote
  %roomnum
  %roomportal
  %roomvnum
  %roomzone
  %round
  %section
  %setglobal
  %sort
  %sql
  %sqldb
  %sqrt
  %state
  %stdev
  %string
  %stripansi
  %stripq
  %subchar
  %subregex
  %sum
  %switch
  %threadid
  %threadname
  %time
  %trigger
  %trim
  %trimleft
  %trimright
  %upper
  %url
  %vartype
  %viewrec
  %walk
  %walkactive
  %walkconfirm
  %walkmode
  %walkroom
  %window
  %word
  %write
  %yesno
  %zonename
  %zonenum
  %zonevnum
Related Links:
  %match
  %subregex
  Comparison
  #REGEX
%regex [[cmud_%regex]] 
regex

Syntax: %regex(s,regular-expression,var1,var2,...varN,varN+1)
Related:
#REGEX, %subregex, %match

test to see if string s matches the given Regular Expression. If it matches, the position of the match in the string is returned (starting with 1). If it doesn't match, zero is returned. The optional VarN arguments contain the names of variables to store any captured subpatterns (subpatterns surrounded by parenthesis). The additional VarN+1 variable name can be specified to hold the length of the matched pattern.

The ($localvar:wildcard) syntax detailed here won't work in %regex. You can use a local variable name instead of a normal variable - %regex will implicitly declare the local variables before giving them values.

Examples:

#SHOW %regex("Zugg says Hi","(\w+) says (.+)",Name,Message,X)
displays 1 and sets the @Name variable to "Zugg", the @Message variable to "Hi" and the @X variable to 12.

#SHOW %regex("Zugg says Hi","(\w+) says (.+)",$Name,$Message,$X)
Same as the above but with local variables.

 User comments 
Arminas: Sun Aug 30, 2009 12:18 am    

It thought I would mention that many of the comments given to the #REG help are also relevant here.

An example of this being that case insensitivity is set to on by default and can be turned off using the (?-i) switch.

Code:
#print {%regex("A Thri-Kreen","(?-i)A Thri-Kreen")}

Output: 1

Code:
#print {%regex("A ThRi-Kreen","(?-i)A Thri-Kreen")}

Output: 0
Viewer Comments [1 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net