Re: backreferences in PCRE?
On Nov 13, 2003, at 2:15 PM, Dar Scott wrote: I mean the negative assertion (?! ). This should also take care of the start. So tinker with this: replaceText(pStr, (?!\\)\\quote, \quote) OK this works: replaceText(pStr, (?!\\)quote, \quote) Thanks Dar! I haven't used assertions much in regex. I'll keep an eye on the bug you mentioned. Although these are just small text chunks so I don't think it'll effect me. Alex Rice [EMAIL PROTECTED] | Mindlube Software | http://mindlube.com what a waste of thumbs that are opposable to make machines that are disposable -Ani DiFranco ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: backreferences in PCRE?
At 2:15 pm -0700 13/11/03, Dar Scott wrote: Yikes. I mean the negative assertion (?! ). This should also take care of the start. So tinker with this: replaceText(pStr, (?!\\)\\quote, \quote) Thanks for the pointer, Dar. It looks like this will do it. put (?!\\) quote into tRegEx replaceText(tStr, tRegEx, \ quote) . Although for this example, this might be easier: replace quote with \ quote in tStr replace \\ quote with \ quote in tStr At 12:40 pm -0700 13/11/03, Alex Rice wrote: I can't remember- are any of Rev's REGEX functions capable of doing backreferences? Alex, it seems you can't backreference in the replacement expression as in Perl, but you can in the find expression, using \1, \2, etc. In Perl, I don't think the $1, $2, etc. in the replacement expression are strictly regular expression elements. They are really special Perl variables. For example, you can use $1 at anytime after a match and it will still hold the matched value.. However, it would be nice to have this ability in Rev, but I don't think $1, etc, would work as it would clash with Rev's environment variables. Cheers Dave ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: backreferences in PCRE?
On Thursday, November 13, 2003, at 02:15 PM, Dar Scott wrote: So tinker with this: replaceText(pStr, (?!\\)\\quote, \quote) I mean this: replaceText(pStr, (?!\\)quote, \quote) I forgot what you were trying to do. Dar ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
RE: backreferences in PCRE?
In transcript I thought it should be : replaceText(pStr, ([^\\])quote, $1\quote) Which works *except* for the $1 is used literally instead of as a backreference. That's because only the second parameter of replaceText() is a match expression; the third param is a simple string. Ken Ray Sons of Thunder Software Email: [EMAIL PROTECTED] Web Site: http://www.sonsothunder.com/ ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
backreferences in PCRE?
I can't remember- are any of Rev's REGEX functions capable of doing backreferences? Consider this perl script. It will put a \ before any quote character, but only if it's not already preceded by a \ character. $txt = fu\bar askldj askld\\\asd lakj sdkljasd\; print before: , $txt, \n; if($txt =~ s/([^\\])/$1\\/g) { print result: , $txt,\n; } # ./test.pl before: fubar askldj askld\asd lakj sdkljasd result: fu\bar askldj askld\asd lakj sdkljasd\ In transcript I thought it should be : replaceText(pStr, ([^\\])quote, $1\quote) Which works *except* for the $1 is used literally instead of as a backreference. Alex Rice [EMAIL PROTECTED] | Mindlube Software | http://mindlube.com what a waste of thumbs that are opposable to make machines that are disposable -Ani DiFranco ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: backreferences in PCRE?
On Thursday, November 13, 2003, at 12:40 PM, Alex Rice wrote: I can't remember- are any of Rev's REGEX functions capable of doing backreferences? You might consider the (?= ) lookbehind assertion. Don't forget the start of the string, too. If you might be matching over 800, see bugzilla 16. Depending on the length of the match, there is a crash when matches get beyond some number. Dar Scott ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: backreferences in PCRE?
On Thursday, November 13, 2003, at 02:08 PM, Dar Scott wrote: I can't remember- are any of Rev's REGEX functions capable of doing backreferences? You might consider the (?= ) lookbehind assertion. Don't forget the start of the string, too. Yikes. I mean the negative assertion (?! ). This should also take care of the start. So tinker with this: replaceText(pStr, (?!\\)\\quote, \quote) Dar Scott ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution