Standard Methods

Note: To view an example, import the V6 R2014 EKL Enhancements.3dxml file located in win_b64\startup\Knowledgeware\EKL Samples\Sample1 in the installation folder. This file shows you examples of use of the SetAttributeInteger, GetAttributeInteger, SetAttributeString, GetAttributeString methods.

This page discusses:

String.NormalizedLength()

Signature

String.NormalizedLength() : Integer

ReturnType

Integer

String.MatchPattern()

Checks if the given string matches the pattern and returns TRUE if it does, and FALSE if it does not.

Signature

String.MatchPattern(iPattern : String) : Boolean

Arguments

NameInput / OutputRequired?TypeComment
iPatternInYesStringPattern name.

ReturnType

Boolean

Example

let referenceString = "testString12345678"
let patternToMatch = "test...ing[1-8]{8}"
Notify(referenceString+" matches "+ patternToMatch +" = #",referenceString.MatchPattern(patternToMatch))
patternToMatch = "test...ing[1-8]{7}"
Notify(referenceString+" matches "+ patternToMatch +" = #",referenceString.MatchPattern(patternToMatch))
patternToMatch = "test...ing[1-5]{8}"
Notify(referenceString+" matches "+ patternToMatch +" = #",referenceString.MatchPattern(patternToMatch))
patternToMatch = ".*1[2-8]*"
Notify(referenceString+" matches "+ patternToMatch +" = #",referenceString.MatchPattern(patternToMatch))

The result of the above example is the following:

testString12345678 matches ...ing[1-8]{8} = true
testString12345678 matches ...ing[1-8]{7} = false
testString12345678 matches ...ing[1-5]{8} = false
testString12345678 matches .*1[2-8]* = true

Note: In the example above:
  • The first pattern matches a string that starts with "test", and that continues with three characters (as the number of points indicates the number of characters to skip), then contains the sequence "ing" and ends with eight digits between 1 and 8. [8] means 8 times the pattern given between [], 1-8 indicates that the character to match is a digit between 1 and 8. The string “testString12345678” and “testString13213745” match this description. True is returned.
  • The second pattern does not match the reference string because it matches a String made of seven digits. The reference has eight digits.
  • The third pattern fails to match the reference string because the eight digits are the end of the string and are out of the [1-5] range.
  • The last pattern describes a string that starts with any character, repeated 0 to n times (it means that the string can start with virtually anything), then contains a "1" followed by digits between 2 and 8. The 1 located before the digits between 2 and 8 is compulsory. The reference string matches this description. True is returned.

String.SearchPattern()

Searches for an occurrence of the pattern in the string and returns it.

Signature

String.SearchPattern(iPattern : String) : String

Arguments

NameInput / OutputRequired?TypeComment
iPatternInYesStringPattern name.

ReturnType

String

Example

let referenceString = "test1test2test3test4"
let patternToSearch = "....1"
Notify("Searching "+ patternToSearch +" in "+referenceString+" found #",referenceString.SearchPattern(patternToSearch))
patternToSearch = "(test[2-9]){2}"
Notify("Searching "+ patternToSearch +" in "+referenceString+" found #",referenceString.SearchPattern(patternToSearch))

The result of the above example is the following:

Searching .... 1 in test1test2test3test4 found test1
Searching (test[2-9]){2} in test1test2test3test4 found test2test3

Note: In the example above:
  • The first pattern matches any string made up of five characters ending with 1.
  • The second pattern matches any string containing "test" and a digit between 2 and 9, repeated twice. The string searched for contains "testXtestY" with X and Y between 2 and 9. Only one search is executed, but it looks for a string containing a repeated pattern.
  • List of supported characters in regular expressions. Regular expressions are a way used to describe strings used to retrieve sub-strings or to check that a given string matches the following criteria:
    /Default escaping character.
    Repetitive patterns
    • o x{n} matches n time x
    • o x{n,m} matches n to m times x
    • o x{n,} matches at least n times x
    • o x? matches 0 or 1 time x
    • o x+ matches at least one time x
    • o x* matches at least 0 time x
    AlternateAlternate operator is | ex: x|y match x pattern or y
    Support range and wildcard
    • . any character
    • /w any word
    • /W any non word
    • /s any space
    • /S any non space
    • /d any digit
    • /D any non digit
    • /x any hexadecimal digit
    • /X any non hexadecimal digit
    • /u matches any upper case character (works only for latin1) [A-ZÂÊÎÔÛÄËÏÖÜ...]
    • /l matches any lower case character (works only for latin1) [a-zâêîôûäëïöü...]
    • /t matches a tab
    • /f matches a form feed
    • /n matches a new line
    • /r matches a carriage return
    • range can be defined using []. "/" is usually more efficient. Example: /d is more efficient than [0-9].

String.ToDimension()

Signature

String.ToDimension(iMagnitude : String) : Magnitude

Arguments

NameInput / OutputRequired?TypeComment
iMagnitudeInYesString-

ReturnType

Magnitude

String.ToReal()

Signature

String.ToReal() : Real

ReturnType

Real