From 8833e15c76729765d0cea6a2f3f3fbef787eb998 Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 14:57:05 -0700 Subject: [PATCH 1/8] Replacement Expression Syntax --- en/howto/search/replacement_expression_syntax.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/en/howto/search/replacement_expression_syntax.md b/en/howto/search/replacement_expression_syntax.md index 62e6947f7..81b8303e9 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. | @@ -40,6 +40,8 @@ the **Replace** dialog box and in the **Replace in Files** dialog box. 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 +71,14 @@ 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 + +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 + +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. From 20f65bf754057d0b5e5b5925fe5fcbebe1ce7159 Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 15:21:35 -0700 Subject: [PATCH 2/8] surpress warning --- conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conf.py b/conf.py index a224d4667..f9066c77f 100644 --- a/conf.py +++ b/conf.py @@ -23,6 +23,7 @@ suppress_warnings = [ 'image.not_readable', 'myst.header', +"myst.xref_missing", ] navigation_depth = 2 html_theme_path = ['_themes'] From e9138d74bc1818f7cddaa6544da98ef6718467d1 Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 16:23:57 -0700 Subject: [PATCH 3/8] Revert "surpress warning" This reverts commit 20f65bf754057d0b5e5b5925fe5fcbebe1ce7159. --- conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conf.py b/conf.py index f9066c77f..a224d4667 100644 --- a/conf.py +++ b/conf.py @@ -23,7 +23,6 @@ suppress_warnings = [ 'image.not_readable', 'myst.header', -"myst.xref_missing", ] navigation_depth = 2 html_theme_path = ['_themes'] From eb85dac6127fa0e2a401c46a64e343045b04f517 Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 16:24:02 -0700 Subject: [PATCH 4/8] ref --- en/howto/search/replacement_expression_syntax.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/en/howto/search/replacement_expression_syntax.md b/en/howto/search/replacement_expression_syntax.md index 81b8303e9..a88518078 100644 --- a/en/howto/search/replacement_expression_syntax.md +++ b/en/howto/search/replacement_expression_syntax.md @@ -23,7 +23,7 @@ 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. See [cell function (beta)](#cell-function-beta). +| \\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 {ref}`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) 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) @@ -36,6 +36,7 @@ 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. From f0eb8f306260ad250c716e56dcfcf1c0ae95ee84 Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 16:29:45 -0700 Subject: [PATCH 5/8] ref --- en/howto/search/replacement_expression_syntax.md | 1 - 1 file changed, 1 deletion(-) diff --git a/en/howto/search/replacement_expression_syntax.md b/en/howto/search/replacement_expression_syntax.md index a88518078..b3ac598bc 100644 --- a/en/howto/search/replacement_expression_syntax.md +++ b/en/howto/search/replacement_expression_syntax.md @@ -36,7 +36,6 @@ 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. From dd1e440da5d0d8acf1ac4d61723bc885bdfe6f02 Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 16:45:52 -0700 Subject: [PATCH 6/8] ref --- en/howto/search/replacement_expression_syntax.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/en/howto/search/replacement_expression_syntax.md b/en/howto/search/replacement_expression_syntax.md index b3ac598bc..34af3a06a 100644 --- a/en/howto/search/replacement_expression_syntax.md +++ b/en/howto/search/replacement_expression_syntax.md @@ -25,8 +25,8 @@ the **Replace** dialog box and in the **Replace in Files** dialog box. | \\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. See {ref}`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) 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) +| \\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 {ref}`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 {ref}`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,6 +36,7 @@ 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. @@ -71,10 +72,12 @@ 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
From 3e5cbe0c831384fd09ef9f38f066616754168cd0 Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 16:55:35 -0700 Subject: [PATCH 7/8] link --- en/howto/search/replacement_expression_syntax.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/en/howto/search/replacement_expression_syntax.md b/en/howto/search/replacement_expression_syntax.md index 34af3a06a..dbd2e766f 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. See {ref}`cell-function-beta`. +| \\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)](replacement_expression_syntax#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) See {ref}`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 {ref}`time-format-example` +| \\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](replacement_expression_syntax#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](replacement_expression_syntax#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,7 +36,6 @@ 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. @@ -72,12 +71,10 @@ 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
From d79b9cf6009242232680c676275c9a2c1f120d0d Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Wed, 21 May 2025 17:01:34 -0700 Subject: [PATCH 8/8] link --- en/howto/search/replacement_expression_syntax.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/en/howto/search/replacement_expression_syntax.md b/en/howto/search/replacement_expression_syntax.md index dbd2e766f..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. See [cell function (beta)](replacement_expression_syntax#cell-function-beta). +| \\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) See [Date format example](replacement_expression_syntax#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](replacement_expression_syntax#time-format-example) +| \\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,6 +36,7 @@ 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. @@ -71,10 +72,12 @@ 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