Find and remove bits of string between { and }
#1

Hey all,

I'm looking for the best way to remove any text in between a { and }, assuming they both exist.
For example
Код:
STRING: {FFFFFF}My String {00FF00}Here
RETURNS: My String Here

AND

STRING: {FFFFFF} My String { Here
Returns: My String { Here
I'm currently using this:
Код:
                        // REMOVE ANY COLOR CODES!!
			new bool:open = false;
			for(new j=0; j<32; j++)
			{
				if(inputtext[j] == '{') open = true;
				if(open == false)
				{
					format(str, sizeof(str), "%s%c", str, inputtext[j]);
				}

				if(inputtext[j] == '}') open = false;
			}
which does the job, but if a player enters a { without closing it, everything after will be ignored.
NOTE: this is just a quick snippit i whipped up.
I was looking as sscanf, but unsure on how to do it. Gave it a good crack tho

Cheers
Reply


Messages In This Thread
Find and remove bits of string between { and } - by [DK]Dark_Knight - 18.12.2018, 06:57
Re: Find and remove bits of string between { and } - by Threshold - 18.12.2018, 09:28
Re: Find and remove bits of string between { and } - by [DK]Dark_Knight - 18.12.2018, 20:55

Forum Jump:


Users browsing this thread: 1 Guest(s)