- Posted by
- Or, you can run a single Perl regular expression replace that will modify only Unix files (and will leave DOS files alone) Find What: (?<!\r)\n Replace With: \r\n The (?<!\r)\n expression says: "match a newline, but only if it is not preceded by a carriage return." Negative lookbehind subexpressions...Posted in Find/Replace/Regular Expressions
-   Topics
-   Views
- ridgerunner
Nov 29, 2009
- A regex is not the right tool for the job. The best you can do with a regex is match multiple lines that are identical. Assuming you are dealing with DOS/Windows line terminations ("\r\n"), Here is a perl style regex that does just that: ^(.*\r\n)\1* But you don't need regex at all. Here is a script...Posted in Scripts
-   Topics
-   Views
- ridgerunner
Sep 05, 2009
- ... However, many thanks again for your lessons. I really appreciate it. You are most certainly welcome! Of all the forums I participate in, (a LOT), you are far and away the most helpful person I have come across. With over 2700 posts, (most of which are in-depth with a very high signal-to-noise r...Posted in Scripts
-   Topics
-   Views
- ridgerunner
Aug 24, 2009
- and Finally... Regarding the regex, it really should be able to match the last line in the file even if there is no line terminator there. It would also be nice if it matches for files having either DOS ('\r\n') or Unix ('\n') line termination styles. And there is no need for any capturing groups, s...Posted in Scripts
-   Topics
-   Views
- ridgerunner
Aug 24, 2009
- and... ... If you just use "^.*?\(.*?[0-9]\).*?(\r\n((?!\(.*?[0-9]\)).)*$|$)" in a JavaScript the Perl engine will get "^.*?(.*?[0-9]).*?(rn((?!(.*?[0-9])).)*$|$)" ... Well, not exactly true. The '\r' and '\n' sequences are valid escape sequences in a JavaScript string and the backslash does NOT nee...Posted in Scripts
-   Topics
-   Views
- ridgerunner
Aug 24, 2009
- Next up... ... The next part is optional reading, but I believe if I'm not mistaken that it shows a bug: ... var txt = "Sample (Entry 1)- 1st line lalala\n2nd line from entry 1 to match\nSecond line to match (Entry 2)- one liner test"; //var RE = new RegExp("^.*?\\(.*?[0-9]\\).*?(\\n((?!\\(.*?[0-9]\...Posted in Scripts
-   Topics
-   Views
- ridgerunner
Aug 24, 2009
- Let me address this thread by responding to the posts in reverse order starting with mofi's most recent... I'm not a JavaScript expert and also not an expert for the regular expression object, but I think when applying a regular expression on a string $ means end of string and not end of line and ^ ...Posted in Scripts
-   Topics
-   Views
- ridgerunner
Aug 24, 2009
- Thank you Mofi for the detailed explanation! The "buggy" UE behaviour now makes perfect sense and is in fact NOT a bug. I have grown used to the perl syntax where OR alternatives are tested in sequence one by one until the first match is found. I just assumed that the UE engine works the same way. O...Posted in Find/Replace/Regular Expressions
-   Topics
-   Views
- ridgerunner
Aug 10, 2009
- There is a problem with OnLineCop's solution - it does not replace a single tab with a single space. Jane's previously mentioned (perl style) solution does work correctly: [ \t]{2,}|\t which, in theory, we should be able to write using the old native UE regex syntax as follows: ^{[ ^t][ ^t]+^}^{^t^}...Posted in Find/Replace/Regular Expressions
-   Topics
-   Views
- ridgerunner
Aug 07, 2009
- By adding a little negative lookahead to the ".*?" portion of pietzcker's perl style regex, you can match nested instances of "word1 word1 blah blah word2 word2" as follows: (?s)\bword1\b(?:(?!\bword1\b).)*?\bword2\b Then you can run this regex recursively to remove nested word1-word2 instances from...Posted in Find/Replace/Regular Expressions
-   Topics
-   Views
- ridgerunner
Jun 12, 2009
- Interesting thread (and challenging problem). This is an excellent example of the type of complex regex problem that is readily solved in one (multi-step) whack with PowerGrep , which can first section the file (eliminating the various kinds of comment lines), then process the remaining lines and ge...Posted in Find/Replace/Regular Expressions
-   Topics
-   Views
- ridgerunner
May 08, 2009
- I'm also experiencing some peculiarities with UE's handling of multi-line regexs. Will report back later...Posted in Find/Replace/Regular Expressions
-   Topics
-   Views
- ridgerunner
Jul 19, 2008
- Thanks for the quick response and suggestions. The idea of using a macro to selectively replace spaces as a function of filetype is somewhat intriguing. In the meantime, I'm using TABINS.EXE and TABDEL.EXE command line utilities which I wrote a long time ago. (Or MSVC if I'm working with C files). I...Posted in UltraEdit General Discussion
-   Topics
-   Views
- ridgerunner
May 18, 2007
- The "Spaces to Tabs (All)" feature needs work (IMHO): 1. It replaces single spaces between words within sentences. This feature should only swap multiple adjacent spaces with tabs. 2. It replaces spaces within quotation marks i.e. quoted strings. I realize that there is another "Spaces to Tabs (Lead...Posted in UltraEdit General Discussion
-   Topics
-   Views
- ridgerunner
May 16, 2007
- Thanks Frank. I did find the official answer to my question on the power tips pages. (Guess I should have looked a little harder before asking. I searched the forums but never looked at the power tips before. There is some good stuff in there...) It appears that the answer is yes and no. Any others ...Posted in UEStudio General Discussion
-   Topics
-   Views
- ridgerunner
Mar 20, 2007