Replace character in string
-
HI, I have a string eg. 000-000-000-000 and I want to replace the last "-" with an "_" Can anyone help me to do this. Thanks
-
HI, I have a string eg. 000-000-000-000 and I want to replace the last "-" with an "_" Can anyone help me to do this. Thanks
Try using regular expressions like:
regex.Replace( yourString, "-", "_")
whereregex
is the regular expression andyourString
is the string in question. Hope this sheds some light :)
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
-
HI, I have a string eg. 000-000-000-000 and I want to replace the last "-" with an "_" Can anyone help me to do this. Thanks
-
HI, I have a string eg. 000-000-000-000 and I want to replace the last "-" with an "_" Can anyone help me to do this. Thanks
-
HI, I have a string eg. 000-000-000-000 and I want to replace the last "-" with an "_" Can anyone help me to do this. Thanks
Is this VB.NET ? If so, then you should use the string. methods, not the ones provided. But, any sort of replace method will replace them all. as someone suggested, if the format is always the same, you can use an index to replace the one character that's in the same place evry time.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert