C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Replace Function


Posted Date: 26 Aug 2008      Total Responses: 2

Posted By: shalini jennifer       Member Level: Gold     Points: 1


Hi,

I have a string say for eg:

dim str as string="3-1/8"x13-1/2"x1'~ARCH~GLULAM~HEADER~DFIR~HEAD~SIMPLE~HEAD"

I want to replace the word "HEAD" to "ABC"

when i use the replace function of .net it correctly replaces HEAD to ABC which is correct and also it replaces HEADER AS ABCER..Which should not happen and is incorrect..How to replace only the word HEAD To ABC and Not HEADER

Thanks in Advance.




Responses

Author: Kundan Kumar Sinha    26 Aug 2008Member Level: GoldRating:     Points: 2
Hi Shalini,

In stead of replacing HEAD with ABC, you replace ~HEAD~ with ~ABC~

It will solve your problem.

Regards,
Kundan


Author: Sreekanth M    28 Aug 2008Member Level: SilverRating:     Points: 6
Hi Shalini,

Actually if from what Kundan says you to replace ~HEAD~ with ~ABC~ then the ~HEAD occuring at the end of the string will also not get replaced as you had wished for earlier. The behavior of replace function is correct and I dont think there is a generic solution for this kind of scenario. You could create a custom replace function that would check if there are no letters that precede or supercede the required string to be replaced. This can be done by checking if the ascii value of the characters lies btw 65-90 or btw 97-122 by getting the integere value of the characters coming before or after the string in concern.



Post Reply
You must Sign In to post a response.
Next : numeric value with decimal only in text box object
Previous : Error when Running a EXE
Return to Discussion Forum
Post New Message
Category: Visual Studio

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use