Register to post in forums, or Log in to your existing account
 

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

Syntax: %subregex(s,regular-expression,NewS)
Related:
#REGEX, %regex, %match

test to see if string s matches the given Regular Expression. If it matches, the matched part of the string is replaced with the NewS string (which is also expanded for any variables or function calls). This continues until there are no more matches of the pattern in the string. The modified string is then returned. This is similar to the #SUB command but substitutes patterns within a string rather than patterns on the screen output. The %1..%99 variables can also be used in the NewS replacement string. Remeber that the pattern is a Regular Expression and not a zMUD trigger pattern.

Examples:

#SHOW %subregex("100 gold, 200 silver", "\d+", "%d")

displays:

%d gold, %d silver

#SHOW %subregex("100 gold, 200 silver", "(\d+)", "%eval(%1+10)")

displays:

110 gold, 210 silver

the quotes "" around the %eval function are needed to prevent %eval from being executed immediately when %subregex is parsed. With the quotes, it is executed each time a string is replaced, which is when %1 is defined.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net