AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Removing from String (https://forums.alliedmods.net/showthread.php?t=299802)

Depresie 07-26-2017 09:26

Removing from String
 
How could i remove from this string
Code:

models/v_weapon.mdl
the following
Code:

models/v_
Code:

.mdl
So it would remain
Code:

weapon

HamletEagle 07-26-2017 09:29

Re: Removing from String
 
Easiest way is with replace.

Depresie 07-26-2017 10:12

Re: Removing from String
 
Thanks, solved

PHP Code:

new szString[32] = "models/v_weapon.mdl"
replace(szStringcharsmax(szString), ".mdl""")
replace(szStringcharsmax(szString), "models/v_"""


Bugsy 07-29-2017 12:46

Re: Removing from String
 
If the start position is known/constant, you can also do this:
PHP Code:

new szTest[] = "models/v_weapon.mdl";
    
szTestsizeofszTest ) - ] = EOS;
    
server_print"[%s]" szTest] ); 

Output:
Code:

[weapon]


All times are GMT -4. The time now is 23:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.