Hi A.M,
Thank you for the reply. I'm sorry for misunderstandin g your problem. Your
problem is to find a method to replace a string with a certain format. In
your case, the string you metioned is such as
"document.form1 .txtName.select ()", I think maybe you can try the Split()
and Join method of the dotnet String class. The two methods can split a
string into string array via a specified char, and combine a string array
via a certain separator string.
For example, you have a string like the "document.form1 .txtName.select ()",
and you want to replace the "txtName" by other string, you can code as this:
private string ReplaceObject(s tring exp, int pos, string sep, string newval)
{
string[] arr = exp.Split(sep.T oCharArray());
arr[pos] = newval;
return string.Join(sep ,arr);
}
thus, you can use it in your code like this:
string original = "document.form1 .txtName.focus( )";
string result = ReplaceObject(o riginal, 2, ".", "txtEmail") ;
you will get the result= "document.form1 .txtEmail.focus ()"
Also, this method can be used for other replacing situation. You can try
the mehotd out to see whether it helps you. If you still feel it unsuitable
for your problem, I think you can think about using the Regex.
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)