tag:blogger.com,1999:blog-6637736252081011583.post3517666419527366768..comments2023-10-23T11:13:47.199-07:00Comments on Daily Vim: Text Editor Tips, Tricks, Tutorials, and HOWTOs: Perl Mass SubstitutionTravis Whittonhttp://www.blogger.com/profile/14592647486468034166noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-6637736252081011583.post-33688535120761341382008-03-24T17:18:00.000-07:002008-03-24T17:18:00.000-07:00Ahh, good point. The often abused dot operator mat...Ahh, good point. The often abused dot operator matches (almost) anything. In an unmodified Perl regexp, it will match any character <I>except</I> a newline. If you add the `s' modifier to the end of your regexp (i.e., /foo/s), it will match newlines as well making it the greediest operator known to man.<BR/><BR/>For the sake of simple example, the greediness is probably ok, but best practices definitely dictate a literal period as Chris said.Travis Whittonhttps://www.blogger.com/profile/14592647486468034166noreply@blogger.comtag:blogger.com,1999:blog-6637736252081011583.post-89422410522653538692008-03-22T14:34:00.000-07:002008-03-22T14:34:00.000-07:00While in most cases involving filename-matching, i...While in most cases involving filename-matching, it doesn't often cause problems, the regex 'index.html' actually matches <I>any string</I> containing the letters 'index' followed by any single character, followed by the letters 'html.' You would want to use the escaped '\.' to represent an actual dot character (so the regex would become 'index\.html').<BR/><BR/>For instance, 'index.html' as a regex would match 'index html' (since the space qualifies as "any character"). So if you had some method with comments reading "this method will index html pages in a directory..." or something, this comment would change to "this method will index.php pages in a directory..."<BR/><BR/>Use the regex but use it mindfully! :DAnonymoushttps://www.blogger.com/profile/04871226658814740333noreply@blogger.comtag:blogger.com,1999:blog-6637736252081011583.post-23290159898125018462008-03-21T10:18:00.000-07:002008-03-21T10:18:00.000-07:00Thanks a lot :) I'm use perl over 5 years and ever...Thanks a lot :) I'm use perl over 5 years and every day finds something newSalvatorhttps://www.blogger.com/profile/02548448929371658822noreply@blogger.com