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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: Fri Jun 13, 2008 3:42 am   

Want help with a subregex
 
The various inputs and outputs are listed below. I used to have a function for this, but it got eaten in the updates from 2.18

Code:

  aardWolf @raard@RW@rolf
  20000000 @R2@r0000000
  20:00:00 @R2@r0:@R0@r0:@R0@r0
  Aardwolf @RA@rardwolf
  AardWolf @RA@rard@RW@rolf
  aardwolf @Ra@rardwolf
  aardwolF @raardwol@RF@r
  AARDWOLF @RAARDWOLF@r OR @RA@rARDWOLF


legend:

word with a capital in the center - highlight the capitals
number - highlight the first digit in the number
number with punctuation - highlight the first digit in each segment (optionally, also highlight the punctuation, up to you)
word with capital at the start - highlight the capitals
word with multiple capitals - highlight the capitals
word with no capitals - highlight the first character
word with capital at the end - highlight the capitals
word that's all capitals - either highlight the whole thing, or the first capital, as long as one of these two conditions is met i don't really mind


Closest i got doesn't highlight all-lowercase

#return %ansi(%eval(%if($Color > 8, $Color - 8, $Color + 8)))%subregex($Input, "(?-i)([^a-z ]*?)(?-i)([^a-z ]+?)(?-i)([^A-Z ]*)", "%ansi("%eval(%if($Color > 8, $Color - 8, $Color + 8))")\1%ansi("$Color")\2%ansi("%eval(%if($Color > 8, $Color - 8, $Color + 8))")\3")
_________________
The Drake Forestseer
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Jun 13, 2008 5:23 am   
 
This covers all of your examples.
Code:
#RETURN %subregex($Input,"(\d|\p{Lu}|\p{Ll}(?=\p{Ll}+\b))(\p{Lu}+)?(\d+|\p{Ll}+|\b)",%concat(%ansi(%bitxor($Color,8)),"\1",%ansi($Color),"\2\3"))
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: Fri Jun 13, 2008 5:42 am   
 
i may possibly love you long time =D

it's official, you = loved long time =D
_________________
The Drake Forestseer
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net