|
-
December 5th, 2007, 06:13 AM
#6
Re: Replace. to _ in a string
Use stringVariable.Replace(".", "_") since you don't seem to know what a regular expression is. stringVariable.Replace(".", "_") will return a new string with "." replaced with "_" in stringVariable, just like you wanted.
With regular expressions, "." means "any character except newline and carriage return". That's why you only get underscores. Regular expressions support escaping, so preceed the dot with a backslash to bypass its special meaning. Since C# also uses backslashes for escaping, you need to escape the backslash as well: "\\."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|