FranciscoR Posted June 14, 2009 Report Share Posted June 14, 2009 (edited) Regexreplace: Replaces the content matched with the regular expression (first argument) with the second argument. The second argument may contain $n as references to groups of the regular expression. http://cdburnerxp.se/help/kb/20 'May' contain $n or 'need' to contain $n ? {var:regexreplace:[^a-z]:.?} Doesn't work; and as far as i can understand (trial-n-error testing), {var:regexreplace:([a-z]+)[^a-z]:$1.?} replaces only the *first* match group, so if i have a filename starting with 'Firefox_Portable_' or '7-Zip_Portable_' doesn't work either. So how can i replace that into something like '7.?Zip.?Portable.?' ? {var:regexreplace:([A-Za-z0-9]+)[^A-Za-z0-9]([A-Za-z0-9]+)[^A-Za-z0-9]([A-Za-z0-9]+)[^A-Za-z0-9]:$1.?$2.?$3.?} This is really complicated the regex i actually have to use with this function is (?-s:{var:regexreplace:([A-Za-z0-9]+)[^A-Za-z0-9]([A-Za-z0-9]+)[^A-Za-z0-9]([A-Za-z0-9]+)[^A-Za-z0-9]:$1.?$2.?$3.?}(\d+(?:\.\d+)+.*?)(?:\.paf\.exe)) Otherwise funtion will span through several lines of code => ERROR. So, can't we improve/simplify this function ? 1.Couldn't we replace ALL matches of each match group? 2.Couldn't we make $n optional ? 3.BTW, any specific reason for this function to be case-sensitive ? This is a bit confusing. -------------------------------- Edited June 14, 2009 by FranciscoR Link to comment Share on other sites More sharing options...
FranciscoR Posted June 14, 2009 Author Report Share Posted June 14, 2009 Update: i've found a way to test this: {appname:regexreplace:[^A-Za-z]:.?} 14-06-2009 19:12:20: SF_Firefox_Portable-Minefield: Determined target file name: D:\Programas\Internet\SF.?Firefox_Portable-Minefield_3.0.11.exe Not working, only the first replacement is done. {appname:regexreplace:([A-Za-z]+)[^A-Za-z]:$1.?} 14-06-2009 19:18:08: SF_Firefox_Portable-Minefield: Determined target file name: D:\Programas\Internet\SF.?Firefox_Portable-Minefield_3.0.11.exe Not working either, same problem as above (and result). {appname:regexreplace:([A-Za-z0-9]+)[^A-Za-z0-9]([A-Za-z0-9]+)[^A-Za-z0-9]([A-Za-z0-9]+)[^A-Za-z0-9]:$1.?$2.?$3.?} 14-06-2009 19:20:10: SF_Firefox_Portable-Minefield: Determined target file name: D:\Programas\Internet\SF.?Firefox.?Portable.?Minefield_3.0.11.exe This one works as expected. Not the best solution, hardly practical. In conclusion, this is #1 request only: to replace ALL matches of each match group. Link to comment Share on other sites More sharing options...
floele Posted June 18, 2009 Report Share Posted June 18, 2009 I'm currently wondering what you are trying to achieve with .? Basically, {appname:regexreplace:[^A-Za-z]:.?} means replace a non-letter with ".?". Link to comment Share on other sites More sharing options...
CybTekSol Posted June 18, 2009 Report Share Posted June 18, 2009 Wow FranciscoR... you are making me dizzy... you sure are getting fancy with 'regexreplace'... lol Link to comment Share on other sites More sharing options...
FranciscoR Posted June 18, 2009 Author Report Share Posted June 18, 2009 Basically, {appname:regexreplace:[^A-Za-z]:.?} means replace a non-letter with ".?". That's it. =) Problems with Sourceforge... Link to comment Share on other sites More sharing options...
floele Posted June 20, 2009 Report Share Posted June 20, 2009 > 1.Couldn't we replace ALL matches of each match group? Will do that for the next version. > 2.Couldn't we make $n optional ? It is. > 3.BTW, any specific reason for this function to be case-sensitive ? This is a bit confusing. It just gives you more possibilities. Link to comment Share on other sites More sharing options...
FranciscoR Posted June 20, 2009 Author Report Share Posted June 20, 2009 (edited) Thanks Flo, > 2.Couldn't we make $n optional ? It is. Yep, i see now. Perfect ! > 3.BTW, any specific reason for this function to be case-sensitive ? This is a bit confusing. It just gives you more possibilities. Ok, maybe you could add 'this function is case-sensitive' to description ?(not a big deal, just because we are used to case-insensivity regexes in Ketarin =)) Edited June 20, 2009 by FranciscoR Link to comment Share on other sites More sharing options...
floele Posted June 20, 2009 Report Share Posted June 20, 2009 Oh, actually you are right with that. Then again, I rather prefer the consistent behaviour. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now