Raised This Month: $51 Target: $400
 12% 

Replace first character in a string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 07-13-2018 , 19:38   Replace first character in a string
Reply With Quote #1

I need function who will replace first character in a string with new value for that character.
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-13-2018 , 20:06   Re: Replace first character in a string
Reply With Quote #2

Elaborate.
__________________
stuff
maqi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-13-2018 , 22:45   Re: Replace first character in a string
Reply With Quote #3

Code:
szString[0] = 'a'
__________________
fysiks is offline
Old 07-14-2018, 06:00
Ghosted
This message has been deleted by Arkshine. Reason: Please don't sarcasm, it's unnecessary and people might not understand.
Old 07-14-2018, 07:00
CrAzY MaN
This message has been deleted by Arkshine. Reason: Answer to deleted message
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 07-20-2018 , 11:35   Re: Replace first character in a string
Reply With Quote #4

I want hardcoded values for each character and function to replace first character with hardcoded value for that character

replaceWith[][] = {"a", "A"}

string = abc

function should return 'Abc'
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 07-20-2018 , 11:49   Re: Replace first character in a string
Reply With Quote #5

https://www.amxmodx.org/api/string/ucfirst
__________________
Relaxing is offline
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 07-20-2018 , 12:05   Re: Replace first character in a string
Reply With Quote #6

Thank you but uppercase was just an example.. mby I want to replace first character with a string
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 07-20-2018 , 13:50   Re: Replace first character in a string
Reply With Quote #7

Quote:
Originally Posted by BaD CopY View Post
Thank you but uppercase was just an example.. mby I want to replace first character with a string
If you want to change the first char of a string then follow fyskis way.
__________________

Last edited by Relaxing; 07-20-2018 at 13:53. Reason: trust me, he nows da wae
Relaxing is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-20-2018 , 21:20   Re: Replace first character in a string
Reply With Quote #8

Quote:
Originally Posted by BaD CopY View Post
Thank you but uppercase was just an example.. mby I want to replace first character with a string
Is this new string going to be a single character or more than one character? If it's always only 1 character, do what I said.
__________________
fysiks is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-21-2018 , 06:02   Re: Replace first character in a string
Reply With Quote #9

Quote:
Originally Posted by BaD CopY View Post
replaceWith[][] = {"a", "A"}

string = abc

function should return 'Abc'
So why 'Abc' instead of 'abc' when replaceWith has both 'a' and 'A' values?

Last edited by edon1337; 07-21-2018 at 06:02.
edon1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-21-2018 , 13:48   Re: Replace first character in a string
Reply With Quote #10

Quote:
Originally Posted by edon1337 View Post
So why 'Abc' instead of 'abc' when replaceWith has both 'a' and 'A' values?
Presumably that is the before and after characters.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:02.


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