- AuthorPosts
- February 11, 2012 at 1:16 pm #9999ldmParticipant
I need a help for writing a JavaScript, which place a character (let’s say the [] brackets) around the highlighted text.
Thank you!February 11, 2012 at 3:20 pm #10002ToadLoadinMemberHi, I’m not a JavaScript geek, but I guess you could use code like:
charBefore = "[;
charAfter = ]";
strSelectedText = document.selection.Text;
document.selection.Text = charBefore + strSelectedText + charAfter;February 11, 2012 at 3:42 pm #10003StefanParticipantYes i do it the same way:
#title = "Enclose selection";
#tooltip = "Enclose an selection with an sign";
// Select some text and execute this macro to put an sign
// in front and at the end of the selected text;
//mySign = "\%"
mySign = prompt( "Enter sign to enclose selection:", "\%" );
selText = document.selection.Text;
outText = mySign + selText + mySign;
//alert(outText);
document.selection.Text = outText;
Should be easy to modify this code
and replace mySign with LeadingSign and TrailingSign :-)February 11, 2012 at 4:29 pm #10004ldmParticipantToadLoadin & Stefan! Thanks a lot!
But now I need one more tip please :-)
Does JavaScript supports Regular Expressions?
Let’s say I need to replace a text, which matches the pattern ^(;[ ]*[ ])(.*) with this one: 1[2]
How would I do so?
Thank you!February 11, 2012 at 9:06 pm #10008StefanParticipantEmEditor Help – EmEditor Macro Reference – Tutorial > Using Regular Expressions
EmEditor Help – How to – Search > Regular Expression Syntax
February 11, 2012 at 9:42 pm #10009ldmParticipantStefan, the issue is not with the RegEx syntax, but how use the RegEx expressions inside of the Java Scripts (please see my previous post).
How should I let to Java know that I wrote a regular expression and not just a string?
Thank you!February 11, 2012 at 10:20 pm #10010ldmParticipantStefan,
I’ve got it!
Thanks! - AuthorPosts
- You must be logged in to reply to this topic.