Skip to content

New text functions - #518

Merged
voodoo11 merged 22 commits into
developfrom
jk/text-functions
Sep 23, 2020
Merged

voodoo11 merged 22 commits into
developfrom
jk/text-functions

Conversation

@voodoo11

@voodoo11 voodoo11 commented Sep 18, 2020 •

Copy link
Copy Markdown
Contributor

Context

Introduces 9 text functions:

EXACT, LOWER, UPPER, MID, T, SUBSTITUTE, REPLACE, UNICODE, UNICHAR

How has this been tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature or improvement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Additional language file or change to the existing one (translations)

Related issue(s):

  1. Add Text functions #159

Checklist:

  • My code follows the code style of this project,
  • My change requires a change to the documentation,
  • I described the modification in the CHANGELOG.md file.

@voodoo11 voodoo11 changed the title Jk/text functions New text functions Sep 18, 2020
@voodoo11
voodoo11 requested a review from izulin September 18, 2020 19:38
| SEARCH | Text | Returns the location of one text string inside another. (Allows the use of wildcards.) | SEARCH( "Text1"; "Text2"[; Number]) |
| FIND | Text | Returns the location of one text string inside another. | FIND( "Text1"; "Text2"[; Number]) |
| SPLIT | Text | Divides text around a specified character or string, and puts each fragment into a separate cell in the row. | SPLIT(Text; Delimiter, [Split_by_each], [Remove_empty_text]) |
| SUBSTITUTE | Text | Returns string where occurrences of Old_text are replaced by New_text. Replaces only specific occurrence if last parameter is provided. | SUBSTITUTE(Text; Old_text; New_text; [Occurrence]) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| SUBSTITUTE | Text | Returns string where occurrences of Old_text are replaced by New_text. Replaces only specific occurrence if last parameter is provided. | SUBSTITUTE(Text; Old_text; New_text; [Occurrence]) |
| SUBSTITUTE | Text | Returns string where occurrences of Old_text are replaced by New_text. Replaces only specific occurrence if last parameter is provided. | SUBSTITUTE(Text; Old_text; New_text[; Occurrence]) |

Comment thread docs/guide/built-in-functions.md Outdated
| LEFT | Text | Extracts a given number of characters from the left side of a text string. | LEFT("Text"; Number) |
| SEARCH | Text | Returns the location of one text string inside another. (Allows the use of wildcards.) | SEARCH( "Text1"; "Text2"[; Number]) |
| FIND | Text | Returns the location of one text string inside another. | FIND( "Text1"; "Text2"[; Number]) |
| SPLIT | Text | Divides text around a specified character or string, and puts each fragment into a separate cell in the row. | SPLIT(Text; Delimiter, [Split_by_each], [Remove_empty_text]) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| SPLIT | Text | Divides text around a specified character or string, and puts each fragment into a separate cell in the row. | SPLIT(Text; Delimiter, [Split_by_each], [Remove_empty_text]) |
| SPLIT | Text | Divides text around a specified character or string, and puts each fragment into a separate cell in the row. | SPLIT(Text; Delimiter[; Split_by_each[; Remove_empty_text]]) |

Comment thread docs/guide/built-in-functions.md Outdated
| LEN | Text | Returns length of a given text. | LEN("Text") |
| TRIM | Text | Strips extra spaces from text. | TRIM("Text") |
| LOWER | Text | Returns text converted to lowercase. | LOWER(Text) |
| MID | Text | Returns substring of a given length starting from Start_position. | MID(Text, Start_position, Length) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| MID | Text | Returns substring of a given length starting from Start_position. | MID(Text, Start_position, Length) |
| MID | Text | Returns substring of a given length starting from Start_position. | MID(Text; Start_position; Length) |

| MIN | Statistical | Returns the minimum value in a list of arguments. | MIN(Number1; Number2; ...Number30) |
| MINA | Statistical | Returns the minimum value in a list of arguments. | MINA(Value1; Value2; ... Value30) |
| CHAR | Text | Converts a number into a character according to the current code table. | CHAR(Number) |
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN("Text") |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN("Text") |
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN(Text) |

Comment thread docs/guide/built-in-functions.md Outdated
| SPLIT | Text | Divides text around a specified character or string, and puts each fragment into a separate cell in the row. | SPLIT(Text, Delimiter, [Split_by_each], [Remove_empty_text]) |
| TEXT | Text | Converts a number into text according to a given format. | TEXT(Number; Format) |
| EXACT | Text | Returns TRUE if both text strings are exactly the same. | EXACT(Text; Text) |
| FIND | Text | Returns the location of one text string inside another. | FIND( "Text1"; "Text2"[; Number]) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| FIND | Text | Returns the location of one text string inside another. | FIND( "Text1"; "Text2"[; Number]) |
| FIND | Text | Returns the location of one text string inside another. | FIND( Text1; Text2[; Number]) |

Comment thread docs/guide/built-in-functions.md Outdated
| TEXT | Text | Converts a number into text according to a given format. | TEXT(Number; Format) |
| EXACT | Text | Returns TRUE if both text strings are exactly the same. | EXACT(Text; Text) |
| FIND | Text | Returns the location of one text string inside another. | FIND( "Text1"; "Text2"[; Number]) |
| LEFT | Text | Extracts a given number of characters from the left side of a text string. | LEFT("Text"; Number) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| LEFT | Text | Extracts a given number of characters from the left side of a text string. | LEFT("Text"; Number) |
| LEFT | Text | Extracts a given number of characters from the left side of a text string. | LEFT(Text; Number) |

Comment thread docs/guide/built-in-functions.md Outdated
| SUBSTITUTE | Text | Returns string where occurrences of Old_text are replaced by New_text. Replaces only specific occurrence if last parameter is provided. | SUBSTITUTE(Text; Old_text; New_text; [Occurrence]) |
| T | Text | Returns text if given value is text, empty string otherwise. | T(Value) |
| TEXT | Text | Converts a number into text according to a given format. | TEXT(Number; Format) |
| TRIM | Text | Strips extra spaces from text. | TRIM("Text") |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| TRIM | Text | Strips extra spaces from text. | TRIM("Text") |
| TRIM | Text | Strips extra spaces from text. | TRIM(Text) |

| MINA | Statistical | Returns the minimum value in a list of arguments. | MINA(Value1; Value2; ... Value30) |
| CHAR | Text | Converts a number into a character according to the current code table. | CHAR(Number) |
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN("Text") |
| CODE | Text | Returns a numeric code for the first character in a text string. | CODE("Text") |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| CODE | Text | Returns a numeric code for the first character in a text string. | CODE("Text") |
| CODE | Text | Returns a numeric code for the first character in a text string. | CODE(Text) |

| CHAR | Text | Converts a number into a character according to the current code table. | CHAR(Number) |
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN("Text") |
| CODE | Text | Returns a numeric code for the first character in a text string. | CODE("Text") |
| CONCATENATE | Text | Combines several text strings into one string. | CONCATENATE("Text1"; ...; "Text30") |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| CONCATENATE | Text | Combines several text strings into one string. | CONCATENATE("Text1"; ...; "Text30") |
| CONCATENATE | Text | Combines several text strings into one string. | CONCATENATE(Text1; ...; Text30) |

Comment thread docs/guide/built-in-functions.md Outdated
| LEN | Text | Returns length of a given text. | LEN("Text") |
| TRIM | Text | Strips extra spaces from text. | TRIM("Text") |
| LOWER | Text | Returns text converted to lowercase. | LOWER(Text) |
| MID | Text | Returns substring of a given length starting from Start_position. | MID(Text, Start_position, Length) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| MID | Text | Returns substring of a given length starting from Start_position. | MID(Text, Start_position, Length) |
| MID | Text | Returns substring of a given length starting from Start_position. | MID(Text; Start_position; Length) |

Comment thread docs/guide/built-in-functions.md Outdated
| TRIM | Text | Strips extra spaces from text. | TRIM("Text") |
| LOWER | Text | Returns text converted to lowercase. | LOWER(Text) |
| MID | Text | Returns substring of a given length starting from Start_position. | MID(Text, Start_position, Length) |
| PROPER | Text | Capitalizes words given text string. | PROPER("Text") |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| PROPER | Text | Capitalizes words given text string. | PROPER("Text") |
| PROPER | Text | Capitalizes words given text string. | PROPER(Text) |

Comment thread docs/guide/built-in-functions.md Outdated
| PROPER | Text | Capitalizes words given text string. | PROPER("Text") |
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN("Text") |
| REPLACE | Text | Replaces substring of a text of a given length that starts at given position. | SUBSTITUTE(Text; Start_position; Length; New_text) |
| REPT | Text | Repeats text a given number of times. | REPT("Text"; Number) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| REPT | Text | Repeats text a given number of times. | REPT("Text"; Number) |
| REPT | Text | Repeats text a given number of times. | REPT(Text; Number) |

Comment thread docs/guide/built-in-functions.md Outdated
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN("Text") |
| REPLACE | Text | Replaces substring of a text of a given length that starts at given position. | SUBSTITUTE(Text; Start_position; Length; New_text) |
| REPT | Text | Repeats text a given number of times. | REPT("Text"; Number) |
| RIGHT | Text | Extracts a given number of characters from the right side of a text string. | RIGHT("Text"; Number) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| RIGHT | Text | Extracts a given number of characters from the right side of a text string. | RIGHT("Text"; Number) |
| RIGHT | Text | Extracts a given number of characters from the right side of a text string. | RIGHT(Text; Number) |

Comment thread docs/guide/built-in-functions.md Outdated
| REPT | Text | Repeats text a given number of times. | REPT("Text"; Number) |
| RIGHT | Text | Extracts a given number of characters from the right side of a text string. | RIGHT("Text"; Number) |
| LEFT | Text | Extracts a given number of characters from the left side of a text string. | LEFT("Text"; Number) |
| SEARCH | Text | Returns the location of one text string inside another. (Allows the use of wildcards.) | SEARCH( "Text1"; "Text2"[; Number]) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| SEARCH | Text | Returns the location of one text string inside another. (Allows the use of wildcards.) | SEARCH( "Text1"; "Text2"[; Number]) |
| SEARCH | Text | Returns the location of one text string inside another. (Allows the use of wildcards.) | SEARCH( Text1; Text2[; Number]) |

Comment thread src/interpreter/plugin/CodePlugin.ts Resolved
Comment thread src/interpreter/plugin/TextPlugin.ts Resolved
}

public substitute(ast: ProcedureAst, formulaAddress: SimpleCellAddress): InternalScalarValue {
return this.runFunction(ast.args, formulaAddress, this.metadata('SUBSTITUTE'), (text: string, oldText: string, newText: string, occurrence: number | undefined) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return this.runFunction(ast.args, formulaAddress, this.metadata('SUBSTITUTE'), (text: string, oldText: string, newText: string, occurrence: number | undefined) => {
return this.runFunction(ast.args, formulaAddress, this.metadata('SUBSTITUTE'), (text: string, oldText: string, newText: string, occurrence?: number) => {

Comment thread test/interpreter/function-exact.spec.ts Resolved
Comment thread test/interpreter/function-lower.spec.ts Resolved
voodoo11 and others added 2 commits September 19, 2020 10:40
Co-authored-by: Przemysław Uznański <40573492+izulin@users.noreply.github.com>
Co-authored-by: Przemysław Uznański <40573492+izulin@users.noreply.github.com>
Comment thread test/interpreter/function-mid.spec.ts Resolved
Comment thread test/interpreter/function-t.spec.ts Resolved
Comment thread test/interpreter/function-upper.spec.ts Resolved
voodoo11 and others added 2 commits September 19, 2020 10:56
Co-authored-by: Przemysław Uznański <40573492+izulin@users.noreply.github.com>
Comment thread docs/guide/built-in-functions.md Resolved
Comment thread src/error-message.ts Resolved
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
@voodoo11
voodoo11 merged commit d83c780 into develop Sep 23, 2020
@voodoo11
voodoo11 deleted the jk/text-functions branch September 23, 2020 18:24
@bardek8 bardek8 mentioned this pull request Sep 24, 2020
17 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants