GML How to cut specific string from a text?

E

Edwin

Guest
Hello, people. Can you please tell me the way how to cut off a specific string from a text? For example to cut "World" from "Hello, World!".
 

Ido-f

Member
Code:
new_string = string_copy(string, character to start copying from (first character's index is 1), numbers of characters to copy).
You can use string_pos to find out the index of a character or a sub-string.
 
L

Luke Norton

Guest
Use the function string_delete().
You need the name of the string, the position/index of the first character to remove (in this case, it would be 8) and the number of characters to remove, so 5.
 
E

Edwin

Guest
One liner:

Code:
new_string = string_replace_all(old_string, "World", "');
Thanks, totally forgot about this function, If you know, could you tell me how I can check what goes after tags in string so I can use and replace them? For example:
Code:
"[spoiler=This is spoiler] SPOILER [/spoiler]"
I can use string_replace to replace , but anyway I need to get the string that goes after equal sign.
 
D

Drepple

Guest
Use string_pos(substr, str) to find the location of a substring in a string, so string_pos("=", str) would give you the position of the equal sign. I assume you don't want to replace the equal sign itself so use that position+1 for replacing, adding, deleting etc. I recommend you look at all the string functions here. Consulting the YoYo Games manual is probably the fastest way to figure out what your looking for / how a function works. Anyways, good luck with your project!
 
Top