- AuthorPosts
- October 5, 2007 at 10:22 am #4722boraMember
Hello everybody!
Have this problem: want to write a macros with regular expression to change all multiple spaces in a document to single spaces.
I use this line:
document.selection.Replace(‘(s){2,}’, ‘1’, eeFindReplaceRegExp | eeReplaceAll);But when I ran this macros in the editor it says (in status bar) that it Cannot find (s){2,} anywhere in document. Note the absence of the backslash before “s” in this status message.
(I also tried to escape the backslash like this (s){2,}, then the “finding” part works, but it replaces it not with a regular space but with a character with code 01H)
Does anyone has any ideas about this problem? I would appreciate any help.
October 5, 2007 at 10:44 am #4723CaptainFlintParticipantJavaScript has its own Escape-character ” and uses it for its own purposes. So, when you write ‘s’ JavaScript converts it into single ‘s’, when you write ‘1’ it is converted into character with octal code 001, etc. The correct expression hence would be:
document.selection.Replace(‘(s){2,}’, ‘1’, eeFindReplaceRegExp | eeReplaceAll);October 5, 2007 at 1:56 pm #4724boraMemberThank you very much, Flint! You helped me out here!
(I’m a beginner in javascript. Started to learn it a couple of days ago after encountering that powerful macro engine in EmEditor. Great tool indeed!) - AuthorPosts
- You must be logged in to reply to this topic.