<RetVar> = substitute in string <Var/String>: pattern <Var/String> with <Var/String>

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Locked
mark_a_condren
Posts: 1385
Joined: Wed, 3. Aug 05, 05:05
x3tc

<RetVar> = substitute in string <Var/String>: pattern <Var/String> with <Var/String>

Post by mark_a_condren » Thu, 16. Sep 10, 17:53

<RetVar> = substitute in string <Var/String>: pattern <Var/String> with <Var/String>


<RetVar> = Variable containing the new string with the substituted text.
<Var/String> = The string you want to substitue the text in.
<Var/String> = The text you want to replace.
<Var/String> = The new text to use in the string.


Returns '-1' if the pattern to be subtituted is not found in the string being checked.
Returns the new string with the old pattern substituted for the new one, if the pattern to be replaced is found in the original string.


Example:

$this.string = 'You have successfuly destroyed the attacking fleet.'
$old.text = 'successfuly destroyed'
$new.text = 'had all your assets totaly destroyed by'

$new.text.string = substitute in string $this.string: pattern $old.text with $new.text

The above example would change,
'You have successfuly destroyed the attacking fleet.'
into,
'You have had all your assets totaly destroyed by the attacking fleet.'


Command Location:
  • »» General Commands
    • »» Strings
      <RetVar> = substitute in string <Var/String>: pattern <Var/String> with <Var/String>

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 21987
Joined: Sun, 2. Apr 06, 16:38
x4

[TiP][49] 287022

Post by X2-Illuminatus » Thu, 14. Oct 10, 17:52

<RetVar> = substitute in string <Var/String>: pattern <Var/String> with <Var/String>


<RetVar> = Variable, die die neue Zeichenkette (string) mit dem neuen Text enthält.
<Var/String> = Die Zeichenkette, in der der Text ersetzt werden soll.
<Var/String> = Der Text, der ersetzt werden soll.
<Var/String> = Der neue Text, der in der Zeichenkette genutzt werden soll.


Gibt '-1' zurück, wenn das gesuchte, zu ersetzende Muster in der überprüften Zeichenkette nicht gefunden wurde.
Gibt die neue Zeichenkette, in der der alte Text durch neuen ersetzt wurde, zurück, wenn das zu ersetzende Muster in der ursprünglichen Zeichenkette gefunden wurde.


Beispiel:

$this.string = 'You have successfuly destroyed the attacking fleet.'
$alter.text = 'successfuly destroyed'
$neuer.text = 'had all your assets totaly destroyed by'

$new.text.string = substitute in string $this.string: pattern $alter.text with $neuer.text

Das obige Beispiel würde,
'You have successfuly destroyed the attacking fleet.'
zu
'You have had all your assets totaly destroyed by the attacking fleet.' ändern.


Zu finden unter:
  • »» General Commands
    • »» Strings
      <RetVar> = substitute in string <Var/String>: pattern <Var/String> with <Var/String>

Locked

Return to “MSCI Reference”