diff --git a/en/howto/search/replacement_expression_syntax.md b/en/howto/search/replacement_expression_syntax.md index 62e6947f7..1369d042e 100644 --- a/en/howto/search/replacement_expression_syntax.md +++ b/en/howto/search/replacement_expression_syntax.md @@ -23,10 +23,10 @@ the **Replace** dialog box and in the **Replace in Files** dialog box. | \\NC | Forces all subsequent substituted characters to converted using [Unicode Normalization Form KC (Compatibility Composition)](../../cmd/convert/unicode_norm_fkc). | | \\ND | Forces all subsequent substituted characters to be converted using [Unicode Normalization Form KD (Compatibility Decomposition)](../../cmd/convert/unicode_norm_fkd). | | \\E | Turns off previous \\L, \\U, \\F, \\H, \\Nc, \\Nd, \\NC, or \\ND. | -| \\J | Specifies that JavaScript is used as the expression. \\J must be placed at the beginning of the replacement expression. Can be combined with back references. The **cell** function can also be used in the script. For instance,
Replacement ExpressionMeaning
\J "\0" + "abc"joins the matched string and "abc"
\J "\0".substr( 0, 5 );returns the first 5 characters of the matched string
\J \0 * 100;multiply a matched number with 100
\J parseFloat( \0 ).toFixed(2);rounds a matched number to 2 decimal places
\J cell( -1 )returns the text in the left neighbor cell, relative to the matched cell.
\J parseFloat( cell( -1 ) )
+ parseFloat( cell( -2 ) )
returns the sum of the two neighboring cells on the left
+| \\J | Specifies that JavaScript is used as the expression. \\J must be placed at the beginning of the replacement expression. Can be combined with back references. The **cell** function can also be used in the script. See [cell function (beta)](#cell-function-beta). | \\V | Same as \\J except that \\V uses the **V8 JavaScript** engine instead of the **Chakra** engine. | -| \\D | If the Date/Time type of a [**Number Range Expression**](number_range_syntax) is used to match a string, this expression specifies a date format. It can be combined with **\\T**. [See available day, month, and year format pictures.](https://docs.microsoft.com/en-us/windows/win32/intl/day--month--year--and-era-format-pictures) For instance, if the matched date/time is "2022-03-31 21:30":
Replacement ExpressionResult
\DM/d/yyyy3/31/2022
\DMMMM, d, yyyyMarch 31, 2022
\D'month='M 'day='d \THH:mmmonth=3 day=31 21:30
-| \\T | If the Date/Time type of a [**Number Range Expression**](number_range_syntax) is used to match a string, this expression specifies a time format. It can be combined with **\\D**. [See available hour, minute, and second format pictures.](https://docs.microsoft.com/en-us/windows/win32/intl/hour--minute--and-second-format-pictures) For instance, if the matched date/time isĀ  "2022-03-31 21:30":
Replacement ExpressionResult
\THH:mm21:30
\Th:mm tt9:30 PM
\THH:mm\D-yyyy-MM-dd21:30-2022-03-31
+| \\D | If the Date/Time type of a [**Number Range Expression**](number_range_syntax) is used to match a string, this expression specifies a date format. It can be combined with **\\T**. [See available day, month, and year format pictures.](https://docs.microsoft.com/en-us/windows/win32/intl/day--month--year--and-era-format-pictures) See [Date format example](#date-format-example) +| \\T | If the Date/Time type of a [**Number Range Expression**](number_range_syntax) is used to match a string, this expression specifies a time format. It can be combined with **\\D**. [See available hour, minute, and second format pictures.](https://docs.microsoft.com/en-us/windows/win32/intl/hour--minute--and-second-format-pictures) See [Time format example](#time-format-example) | (?Ntrue\_expression:false\_expression) | If sub-expression N was matched, then true\_expression is evaluated and sent to output, otherwise false\_expression is evaluated and sent to output. For example, (?1foo:bar) will replace each match found with foo if the sub-expression \\1 was matched, and with bar otherwise. Alternatively, you can write the expression in this form: (?{1}foo:bar) | | $(Path) | File path. | | $(Dir) | File directory. | @@ -36,10 +36,13 @@ the **Replace** dialog box and in the **Replace in Files** dialog box. | $(Lines) | Number of lines (cannot be used in **Replace in Files**). | | $(CsvColumns) | Number of CSV columns (cannot be used in **Replace in Files**). | +(cell-function-beta)= ## cell function (beta) The **cell** function can be used in JavaScript if **\\J** is also specified. This function retrieves the text in the specified CSV cell. +
Replacement ExpressionMeaning
\J "\0" + "abc"joins the matched string and "abc"
\J "\0".substr( 0, 5 );returns the first 5 characters of the matched string
\J \0 * 100;multiply a matched number with 100
\J parseFloat( \0 ).toFixed(2);rounds a matched number to 2 decimal places
\J cell( -1 )returns the text in the left neighbor cell, relative to the matched cell.
\J parseFloat( cell( -1 ) )
+ parseFloat( cell( -2 ) )
returns the sum of the two neighboring cells on the left
+ ### #### \[JavaScript\] @@ -69,6 +72,16 @@ Specifies a combination of the following values. 0, 1, and 2 cannot be used toge | 2 | The returned text may include surrounded double-quotes and delimiters. | | 8 | _iColumn_ and _yLine_ parameters are expressed in 1-based absolute values. | +(date-format-example)= +## Date format example + +If the matched date/time is "2022-03-31 21:30":
Replacement ExpressionResult
\DM/d/yyyy3/31/2022
\DMMMM, d, yyyyMarch 31, 2022
\D'month='M 'day='d \THH:mmmonth=3 day=31 21:30
+ +(time-format-example)= +## Time format example + +If the matched date/time is "2022-03-31 21:30":
Replacement ExpressionResult
\THH:mm21:30
\Th:mm tt9:30 PM
\THH:mm\D-yyyy-MM-dd21:30-2022-03-31
+ ## Notes Many new methods in modern JavaScript/ECMAScript are not available in EmEditor. The Replace Expressions use Chakra (equivalent to Microsoft Edge Legacy), and support up to ECMAScript 5.1, thus newer methods introduced after ECMAScript 5.1 are not supported.