A strange question, but I will not waste time explaining why I need to do this, just to do it.
I have the following:
<input type="radio" name="eq_9" id="eq_9_2" onclick="nextStepID_load(this);" value="Installer." title="912" /><label for="eq_9_2">Installer</label> <br />
I need to turn this into:
<button type="button" name="eq_9" id="eq_9_2" onclick="nextStepID_load('912');">Installer</button><br />
I use C # / asp.net (3.5 or lower) and javascript for executeJS (which is a placeholder until I figure out how to replace html).
Note: the source providing this sends me a line with MANY input lines. And I need to replace each line with information that is valid for her.
Currently, I have tried adding .Replace ("," \ ">"), which replaces the radio libraries, but obviously makes it look awful in code and does not remove the shortcut or put the contents of the shortcuts between the tags.
I'm sure this is probably best resolved by regex, but I'm not very familiar with regex. I played with regexlib to find out if I can find the regex myself ... that's what I have so far, although I think I'm pretty far away.
string strRegex = @"<input type=""radio"" [\s]*=[\s]*""?[^\w_]*""?[^>]*>";
RegexOptions myRegexOptions = RegexOptions.IgnoreCase | RegexOptions.Multiline;
Regex myRegex = new Regex(strRegex, myRegexOptions);
string strTargetString = @"<input type=""radio"" name=""eq_9"" id=""eq_9_2"" onclick=""nextStepID_load(this);"" value=""Installer."" title=""912"" /><label for=""eq_9_2"">Installer</label> <br />";
string strReplace = "<button type="button"></button>";
return myRegex.Replace(strTargetString, strReplace);
source
share