Remove special chars
Hi, how to remove special chars from string?
If I have this string "[@string()]", how to get just "string"? |
Re: Remove special chars
you can create a new string, then with a loop process each character and look if it's right
I don't know about pawn but in other languages, string[i] is the ascii value of the character so you can probably do something like if(x<string[i]<y) where x is the ascii for a and y is capital Z |
Re: Remove special chars
you can use isalpha() for that too:
PHP Code:
|
Re: Remove special chars
Can't you just use 'replace_all()' and replace your symbols? If they are more than 1 symbol, just put them in const and loop trough them, replacing all with nothing (""). Wouldn't this work?
|
Re: Remove special chars
It would. But he want's to remove all special chars, so you could as well just use something like above. I guess replace_all() doesn't do much more than looping through a string, so it's basicly the same I'd say.
|
Re: Remove special chars
I do this, but may be regex will be better?
PHP Code:
|
Re: Remove special chars
Using replace_all() will not be very efficient having to loop through all non-letter characters. Regex may or may not be what you want. If you simply want to remove non-letter characters, it is best to do as aron9forever said.
|
| All times are GMT -4. The time now is 21:16. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.