- AuthorPosts
- August 29, 2019 at 6:38 am #26140DavidParticipant
In EmEditor help system, there are some Javascript samples of \J in Replacement of Regular Expression.
http://www.emeditor.org/en/howto_search_replacement_expression_syntax.htmlReplacement Expression Meaning \J "\0" + "abc" joins the matched string and "abc" \J substr( "\0", 0, 5 ) returns the first 5 characters of the matched string
I try the first replacement expression \J “\0” + “abc” , it works very well. But when I try the second one,there’s an error dialog “macro error: ‘substr’ is not defined”. What’s reason for this error?
Another question, besides ‘substr()’,if possible to use other JS Functions, such as getDate(),getYear(),…….Thanks!
August 29, 2019 at 10:05 am #26141Yutaka EmuraKeymasterIt should be written as:
\J "\0".substr( 0, 5 )
We will fix the Help.
You can use any JavaScript script here. For instance:
\J var d = new Date(); d.getFullYear() + "-" + ( d.getMonth()+1 ).toString() + "-" + d.getDate();
Thank you,
August 29, 2019 at 5:54 pm #26142DavidParticipantHello,Yutaka Sung, Thanks for your quick reply.
I made an incorrect description. My second question is: in the Replacement Expression
\J "\0".substr( 0, 5 )
Besides .substr() in the \J expression, if possible to use other Functions.For example:\J "\0".Left( 0, 5 ) \J "\0".Right( 0, 5 ) \J "\0".Upper( ).......
In the help system, only .substr is mentioned.
August 30, 2019 at 10:07 am #26146Yutaka EmuraKeymasterHello David,
You can use any JavaScript String methods. “\0” is considered a String. Left and Right are not JavaScript, but you can use any other JavaScript methods here. Please refer to JavaScript string methods:
- AuthorPosts
- You must be logged in to reply to this topic.