|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Mon Feb 04, 2008 9:47 am
%subregex and @ |
Has anyone figured out how to sub an @ symbol into a string yet? i've tried using @, ~@, \@, \~@, \~\@, ~\@, %char(64), %char(34)@%char(34), but none of them work :(
Code: |
#return %subregex($Input, "((?-i)[A-Z0-9])((?-i)[a-z0-9]*)", "_"$Color"%pat(1)_"%if($Color==%lower($Color),%upper($Color),%lower($Color))"%pat(2)")
|
that's a version with @ replaced with _ in the code, i'm hoping to eliminate the need to wrap the subregex in a regular replace statement |
|
_________________ The Drake Forestseer |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Feb 04, 2008 11:04 am |
Try using explicit concatenation first. If that isn't enough then we might try an additional concat.
Code: |
#return %subregex($Input, "((?-i)[A-Z0-9])((?-i)[a-z0-9]*)", %concat("@",$Color,"%pat(1)@",%if($Color==%lower($Color),%upper($Color),%lower($Color)),"%pat(2)")) |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Mon Feb 04, 2008 11:07 am |
I'm trying to upgrade the regexp at the moment acutally to follow an even more complex set of rules, feel free to give hints if you want ;)
Code: |
this is a test THAT SHOWS All Possible ansiHighlight Combinations Including 09:09 Times Like That.
+t-this +i-s +a- +t-est +T-HAT +S-HOWS +A-ll +P-ossible -ansi+H-ighlight +C-ombinations +I-ncluding +0-9+:0-9 +T-imes +L-ike +T-hat.
|
i'll change the + and - later (stand for +Bright, and -Dark colors) |
|
_________________ The Drake Forestseer |
|
|
|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Mon Feb 04, 2008 11:16 am |
At the moment, the one part that fails is the match on "ansiHighlight" (ie capital in mid-word)
Code: |
$Input = %subregex(" "$Input, "((?-i)[^a-zA-Z0-9])((?-i)[a-z])((?-i)[a-z]*)", "%pat(1)+%pat(2)-%pat(3)")
$Input = %subregex(" "$Input, "((?-i)[a-z]*)((?-i)[A-Z0-9])((?-i)[a-zA-Z0-9]*)((?-i)[^a-zA-Z0-9])", "%pat(1)+%pat(2)-%pat(3)%pat(4)")
#return %trim($Input)
|
Code: |
+t-his +i-s +a- +t-est +T-HAT +S-HOWS +A-ll +P-ossible +a-nsi+H-ighlight +C-ombinations +I-ncluding +0-9:+0-9 +T-imes +L-ike +T-hat.
|
|
|
_________________ The Drake Forestseer |
|
|
|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Mon Feb 04, 2008 11:34 am |
Code: |
#return %replace("_char(64)"%if(%lower($Color) == $Color, %upper($Color), %lower($Color))%subregex(%subregex(%subregex(" "$Input" ", "((?-i)[a-z]*)((?-i)[A-Z0-9])((?-i)[a-zA-Z0-9]*)((?-i)[^a-zA-Z0-9])|((?-i)[a-z])((?-i)[a-z]+)((?-i)[^a-zA-Z0-9])| (?-i)([a-z]) ", "%if(%len(%pat(2)), %concat(%pat(1), _char(64)"$Color", %pat(2), _char(64)"%if(%lower($Color) == $Color, %upper($Color), %lower($Color))", %pat(3), %pat(4)))%if(%len(%pat(6)), %concat(_char(64)"$Color", %pat(5), _char(64)"%if(%lower($Color) == $Color, %upper($Color), %lower($Color))", %pat(6), %pat(7), %pat(8)))"), " (?-i)([a-z]) ", " _char(64)"$Color"%pat(1) "), "^ | $", ""), "_char(64)", "@")
|
Does the job, doesn't highlight the : between the time, but that was optional anyways, the important bits are working :D
Tried Concatting the @ in, didn't work properly :( |
|
_________________ The Drake Forestseer |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Tue Feb 05, 2008 1:06 am |
Posted before I tested, my bad
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
|
|
|
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
|
|