ScriptForge.String service

The String service provides a collection of methods for string processing. These methods can be used to:

Meghatározások

Sortörések

The String service recognizes the following line breaks:

Szimbolikus név

ASCII-kód

Line feed
Vertical tab
Carriage return
Line feed + Carriage return
File separator
Group separator
Record separator
Next line
Line separator
Paragraph separator

10
12
13
10 + 13
28
29
30
133
8232
8233


Üres karakterek

The String service recognizes the following whitespaces:

Szimbolikus név

ASCII-kód

Space
Horizontal tab
Line feed
Vertical tab
Form feed
Carriage return
Next line
No-break space
Line separator
Paragraph separator

32
9
10
11
12
13
133
160
8232
8233


Escape sorozatok

Below is a list of escape sequences that can be used in strings.

Escape sorozat

Szimbolikus név

ASCII-kód

\n
\r
\t

Line feed
Carriage return
Horizontal tab

10
13
9


tip

To have the escape sequence "\n" interpreted as an actual string, simply use "\\n" instead of "\" & Chr(10).


Nem nyomtatható karakterek:

Characters defined in the Unicode Character Database as “Other” or “Separator” are considered as non-printable characters.

Control characters (ascii code <= 0x1F) are also considered as non-printable.

Quotes inside strings:

To add quotes in strings use \' (single quote) or \" (double quote). For example:

A szolgáltatás igénybevétele

Before using the ScriptForge.String service the ScriptForge library needs to be loaded using:

In Basic

      GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
  

Loading the library will create the SF_String object that can be used to call the methods in the String service.

The following code snippets show the three ways to call methods from the String service (the Capitalize method is used as an example):


    Dim s as String : s = "abc def"
    s = SF_String.Capitalize(s) ' Abc Def
  

    Dim s as String : s = "abc def"
    Dim svc : svc = SF_String
    s = svc.Capitalize(s) ' Abc Def
  

    Dim s as String : s = "abc def"
    Dim svc : svc = CreateScriptService("String")
    s = svc.Capitalize(s) ' Abc Def
  
In Python

The code snippet below illustrates how to invoke methods from the String service in Python scripts. The IsIPv4 method is used as an example.


    from scriptforge import CreateScriptService
    svc = CreateScriptService("String")
    ip_address = '192.168.0.14'
    svc.IsIPv4(ip_address) # True
  

Tulajdonságok

The SF_String object provides the following properties for Basic scripts:

Név

Írásvédett

Leírás

sfCR

Igen

Carriage return: Chr(13)

sfCRLF

Igen

Carriage return + Linefeed: Chr(13) & Chr(10)

sfLF

Igen

Linefeed: Chr(10)

sfNEWLINE

Igen

Carriage return + Linefeed, which can be
1) Chr(13) & Chr(10) or
2) Linefeed: Chr(10)
depending on the operating system.

sfTAB

Igen

Horizontal tabulation: Chr(9)


tip

You can use the properties above to identify or insert the corresponding characters inside strings. For example, the Linefeed can be replaced by SF_String.sfLF.


List of Methods in the String Service

Capitalize
Count
EndsWith
Escape
ExpandTabs
FilterNotPrintable
FindRegex
HashStr
HtmlEncode
IsADate
IsAlpha
IsAlphaNum
IsAscii
IsDigit
IsEmail

IsFileName
IsHexDigit
IsIBAN
IsIPv4
IsLike
IsLower
IsPrintable
IsRegex
IsSheetName
IsTitle
IsUpper
IsUrl
IsWhitespace
JustifyCenter
JustifyLeft

JustifyRight
Quote
ReplaceChar
ReplaceRegex
ReplaceStr
Represent
Reverse
SplitLines
SplitNotQuoted
StartsWith
TrimExt
Unescape
Unquote
Wrap


note

A legtöbb metódus első argumentuma a figyelembe veendő karakterlánc. Ezt mindig hivatkozással adjuk át, és változatlanul hagyjuk. Az olyan metódusok, mint a Capitalize, Escape, stb. a végrehajtásuk után egy új karakterláncot adnak vissza.


warning

Mivel a Python átfogó beépített karakterlánc-támogatással rendelkezik, a String szolgáltatás legtöbb metódusa csak Basic parancsfájlok számára érhető el. A Basic és Python számára elérhető metódusok a következők: HashStr, IsADate, IsEmail, IsFileName, IsIBAN, IsIPv4, IsLike, IsSheetName, IsUrl, SplitNotQuoted és Wrap.