String Manipulation

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands >

String Manipulation

GNF. - Get Negative Filtered String

Previous Top Next


Intention

The `GNF.` command filters a string by **removing** all characters specified in a second string. Any character in the input string that is also present in the "remove characters" string will be deleted. It essentially performs a `REMOVE$, ANY` operation.

 

Syntax

GNF.P1|P2[|P3]

The command takes either 2 or 3 parameters separated by the pipe symbol (`|`).

Parameter Forms:

-GNF.P1|P2(2 Parameters - In-Place Modification)- P1: Input/Output Variable (`$$VAR`) containing the string to filter.- P2: Characters to Remove (`$$VAR` or literal string).- Output: The variable specified in P1 is modified directly (in-place).

-GNF.P1|P2|P3(3 Parameters - Output to P3)- P1: Input Variable (`$$VAR`) containing the string to filter.- P2: Characters to Remove (`$$VAR` or literal string).- P3: Output Variable (`$$VAR`) where the filtered result will be stored.- Output: The result is stored in the variable specified in P3. P1 remains unchanged.

-(Note: Input/Output handling primarily focuses on variables, similar to `GPF.`.)

 

Parameters Details




Param

Type

Description

P1

Input Variable (`$$VAR`)

Required. The variable containing the string to be filtered. Assumed to use `Vari_Bin` resolution (no further expansion). If only 2 parameters are provided, this variable will be overwritten with the result.

Example: $$SRC

P2

Characters to Remove (Variable or String)

Required. A string containing all the characters that should be removed from the input string (P1). This can be a variable (`$$VAR`) or a literal string. Every occurrence of any character present in P2 will be removed from P1.

Example: $$VOW = "aeiou"

Example: "-*[]"

P3

Output Variable (`$$VAR`)

Optional. If provided, this variable will receive the filtered result. The input variable (P1) will remain unchanged in this case.

Example: $$RES

 

Execution Flow

The `GNF.` command executes as follows:

The command verifies if 2 or 3 parameters were provided.

It determines the target output variable: P3 if provided, otherwise P1.

The content of the input variable (P1) is retrieved (using `Vari_Bin` resolution).

The "Characters to Remove" string (P2) is retrieved.

The core filtering operation `Remove$(InputString, ANY CharsToRemove)` is performed.

The resulting filtered string is stored in the target output variable (P3 or P1).

 

Examples

Example 1: Remove Digits (In-Place)

' Goal: Remove all digit characters from $$SRC

VAR.$$SRC="Item Code: ABC-123-DEF-456"

VAR.$$DIG="0123456789" ' Characters to remove

' Use 2 parameters: Input/Output is $$SRC (P1), Remove chars are in $$DIG (P2)

GNF.$$SRC|$$DIG

PRT.Result: $$SRC

' Output: Result: Item Code: ABC--DEF-

ENR.

Example 2: Remove Specific Symbols (Output to P3)

' Goal: Remove brackets and hyphens, store result in $$RES

VAR.$$INP="[Part-A] - [Part-B]"

VAR.$$SYM="[]-" ' Characters to remove

VAR.$$RES= ' Clear or initialize result variable

' Use 3 parameters: Input $$INP (P1), Remove $$SYM (P2), Output $$RES (P3)

GNF.$$INP|$$SYM|$$RES

PRT.Original: $$INP

PRT.Result: $$RES

' Output:

' Original: [Part-A] - [Part-B]

' Result: PartA PartB

ENR.

Example 3: Using Literal String for Remove Characters

' Goal: Remove vowels (case-insensitive by listing both cases)

VAR.$$SRC="Quick Brown Fox"

' Use 2 parameters: In-place modify $$SRC (P1)

' P2 is a literal string containing vowels to remove

GNF.$$SRC|"aeiouAEIOU"

PRT.Result: $$SRC

' Output: Result: Qck Brwn Fx

ENR.

Example 4: Demonstrating Case Sensitivity

' Goal: Remove only lowercase 'a'

VAR.$$INP="Alpha Bravo Charlie alpha bravo charlie"

VAR.$$RES=

' Use 3 parameters: Output to $$RES, remove only 'a' (P2)

GNF.$$INP|"a"|$$RES

PRT.Result: $$RES

' Output: Result: Alph Bravo Charlie lph brvo chrlie

ENR.

Remarks

·`GNF.` is a simplified command for removing specific characters, similar to using the `y` prototype in `GFS.` (`GFS.y`) after defining the characters to remove.

·The operation is case-sensitive. To remove both 'a' and 'A', include both in the "Characters to Remove" string (P2).

·Like `GPF.`, the input variable (P1) is resolved using `Vari_Bin`, preventing accidental expansion of system or nested variables within the string being filtered.

·Ensure variable names conform to the `$$` + 3 characters rule.

·For more advanced filtering (like keeping characters, using predefined sets, immediate actions like removing control characters, or multi-step processing), use the more versatile `GFS.` command.

·This command is useful for quick cleanup tasks where you simply need to remove a known set of unwanted characters.

 

See also:

 

  GPF. - Get Positive Filtered String

  GFS. - Get Filtered String

  STR. - String Operations

  RPL. - Replace in String

  Variable Commands (VAR., VAB., etc.)