On 8/24/05, Steve Johnson <[EMAIL PROTECTED]> wrote: > Daniel Michaeloff wrote: > > > I want to replace '%' with an expression in a string, except for escaped > > '%%' which should go to '%'. > > The key is to use the lookahead/lookbehind grouping constructs. > > (?<=[^%])%(?=[^%]) > > ...works for me. The first group says "where the previous character > is not a %" and the second group says "where the next character is not > a %". Neither grouping construct matches the check character.
OK, both Steve and Janis have solutions that may work, with fixes, but they don't work as supplied: ; Mine > (Regex:Replace "a%b%%c%%%d%%%%e%%%%%f" "%%|%"(make-delegate > MatchEvaluator.(m)(if(== m.Value "%%") "%""PCNT"))) aPCNTb%c%PCNTd%%e%%PCNTf ; Janis > (Regex:Replace "a%b%%c%%%d%%%%e%%%%%f" "(^|[^%])([%])([^%]|$)" "$1PCNT$3") aPCNTb%%c%%%d%%%%e%%%%%f ; Steve > (Regex:Replace "a%b%%c%%%d%%%%e%%%%%f" "(?<=[^%])%(?=[^%])" "PCNT") aPCNTb%%c%%%d%%%%e%%%%%f =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com