--- In [email protected], Julien Pierrehumbert <[EMAIL PROTECTED]> wrote: > > > I'm not sure if it's necessary at this stage, already we have two > > separate services, match/replace and matchg/replaceg, and Bruce > > introduced a way to manage it in var[?"string"] syntax. > > I haven't yet used or even read the documentation of Bruce's new syntax > so I don't know how he dealt with that... but I figured it would be > better to have some consistency between the behaviour of the plugin's > services and PP's new syntax. Wouldn't it be confusing if (?#-g) was not > interpreted in the same way in all instances?
As (?#...) is just an embedded comment, it won't affect anything on the regex engine's side. It's just a signal from which PP switches between replace/match and replaceg/matchg: if the default is global match/replace, (?#1) tells PP to switch to single match/replace if the default is single match/replace, (?#g) tells PP to switch to global match/replace (?#g) in global case and (?#1) in single case won't do anything, I suppose. However, I'd like to hear about what you have in mind regarding the global switch. Bruce may be interested in it too. > > However, it may be of help with regex.rg(), or would-be regex.mg(), > > when one does not want to introduce a variable. > > Sorry, I don't get it. Care to elaborate? I noticed that recently I abridged too much my statements, so it could be easily sort of encryption. Anyway, what I was talking about was: Sometimes I don't want to introduce a variable only for the returned result of regex. However, all replace(g)/match(g) services need a variable to return the result to. And the new syntax of PP also needs a variable in replace case like var[?"pattern"] = ?"replace" Although it does not need a variable for the returned result in match case like (any_expression)[?"pattern"] the usage may be somewhat restricted as ?"replace" should be pre-coded in match case, which actually is \0\n. So, I can't use the following case in PP's syntax regex.match(?"Hello [World]",?"\[(.*)\]",?"\1") In the simple cases like this one may find an easy work-around like ?"Hello [World]"[?"(?<=\[)(.*)(?=\])"] however, it's highly unlikely in complicated cases. Then, one has to use regex.match() which needs a variable for the returned result. As now we have rg/mg services, one can use them in global case, however, no way in single case yet. (OK, one can manage it indirectly using line()/word() on the results of rg/mg, so, it may not be a big deal) > > I'm interested. BTW, does it happen to have regex.mg() service? :) > > No, but I've just added one. Thanks. > Here's for *testing*: > http://julp.curvedspaces.com/regexpcre6.zip > I compiled that against GnuWin32's latest PCRE build... and this time > the plugin ended up linked to the POSIX library as well. Did I make a > mistake this morning? > Anyway, if you want your .mg, you'll have to test PCRE6 compatibility > for us. ;-) Watch out for memory leaks as well. It works fine in my quick tests. As a matter of fact, I've been using the latest pcre3.dll with the old regex.dll quite a while and never met an incompatibility problem till now. Maybe 'cause my usage was rather casual? Possibly... Sean ------------------------ Yahoo! Groups Sponsor --------------------~--> See what's inside the new Yahoo! Groups email. http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/JV_rlB/TM --------------------------------------------------------------------~-> Attention: PowerPro's Web site has moved: http://www.ppro.org Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/power-pro/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
