Skip to content

UTL

Introduction

The UTL pre-defined object provides the utility functions described below.

string_to_number

The string_to_number method converts a number expressed in letters into a number possibly multiplied by a factor.

For example, after the following instruction:

var strToNumber = UTL.string_to_number("EN", "onehundredseventyfive", "*M");  

variable strToNumber is set to 175000000, that is 175 multiplied by 1000000.

The syntax is:

UTL.string_to_number(lang, string, factor)

where:

  • lang is the language code. It can be:
    • EN for English
    • IT for Italian
    • DE for German
    • ES for Spanish
  • string is the number expressed in letters to convert.
  • factor is a multiplication factor, and it can assume one of the following values:

    Value Multiplication factor
    Empty string 1
    *K (kilo) 1x103
    *M (mega) 1x106
    *G (giga) 1x109
    *T (tera) 1x1012
    *m (milli) 1x10-3
    *u (micro) 1x10-6
    *n (nano) 1x10-9
    *p (pico) 1x10-12

The returned value is a string.
If the string to be converted is not a number—for example book—the method returns -1.

rebase_position

Some intrinsic features of the text intelligence engine and scripting functions, used in the preparation phase, can alter the original input text.
The rebase_position heuristically determines the position in which a character of the text was in the original text, if, due to manipulation, it has changed its place.

For example if, with the script used as an example of the addREGEXSelectBackref method of the regexcleaner module, the original text:

Heeeeeey duuuuude! I looooove that book.

becomes:

Hey dude! I looooove that book.

the that word has moved. The character that was in position 31 (the initial t) in the original text is now in position 22.

The result of this instruction:

UTL.rebase_position(22)

performed after the manipulation, will therefore be 31.

The syntax of the method is:

UTL.rebase_position(index)

where index is the position of a character in the current input text.