EmEditor (text editor) Forum Index Questions and Answers about Macros
Question about Find/Replace with RegExp and Backslash | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| jowra | Posted on: 3/24/2010 10:19 am |
Just popping in ![]() ![]() Joined: 3/24/2010 From: Posts: 2 |
Question about Find/Replace with RegExp and Backslash Hello!
First of all, thank you for this great editor! Currently I'm trying to write my frist macros and would like to find and replace some strings: For example search for: (1) or (2) or (3) and so on... I would like to replace such a string with: \absatz So for the moment I'm just trying the Find method and use the following: document.selection.Find("\(.\)", eeFindNext | eeFindReplaceRegExp); But that macro "finds" all characters, since only the dot-operator is used. But if I use this regular expression in the replace-dialog it works like it should be. I've tried other combinations in the macro, for instance [0-9] finds all numbers, thats correct, but as soon as I use the blackslash-char, it is simply ignored. And if - for testing reasons - I search for a simple string that works and would like to replace it with a LaTex-command like \section, the backslash is ignored again even if I use \\section. Am I doing something completly wrong? Thanks for any hint. |
| Yutaka | Posted on: 3/24/2010 12:13 pm |
Webmaster ![]() ![]() Joined: 9/28/2006 From: Redmond Posts: 2424 |
Re: Question about Find/Replace with RegExp and Backslash Hello jowra,
Thank you for using EmEditor! If you use JavaScript macros, you will need to escape a backslash as four backslashes like '\\\\'. This is because Regular Expressions need one escape, and then JavaScript language also needs one escape. I hope this makes sense you. If you have further questions, please don't hesitate to ask me. Thanks again!
|
| jowra | Posted on: 3/24/2010 12:33 pm |
Just popping in ![]() ![]() Joined: 3/24/2010 From: Posts: 2 |
Re: Question about Find/Replace with RegExp and Backslash That works perfect!
Thank you Yutaka! |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |




