BeginningWebDesign
asked on
Variables in regular expressions problem
Hi
Can anyone tell me where I'm going wrong here.
string HighlightWord, Word1;
If I run the code below it works OK
HighlightWord = Regex.Replace(HighlightWor d, "harry", "<strong>harry</strong>", RegexOptions.IgnoreCase);
But when I try and change harry to a variable it will not work, can anyone tell me what I need to change
HighlightWord = Regex.Replace(HighlightWor d, "Word1", "<strong>Word1</strong>", RegexOptions.IgnoreCase);
Regards
Caz
Can anyone tell me where I'm going wrong here.
string HighlightWord, Word1;
If I run the code below it works OK
HighlightWord = Regex.Replace(HighlightWor
But when I try and change harry to a variable it will not work, can anyone tell me what I need to change
HighlightWord = Regex.Replace(HighlightWor
Regards
Caz
Its strange... Does HighlightWord string has "Word1"? If it has, surely it must get replaced by "<strong>Word1</strong>".
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BeginningWebDesign,
There is something wrong with your question. Wanna fix your question, rephrase it or whatever, so we'll understand better?
:-)
There is something wrong with your question. Wanna fix your question, rephrase it or whatever, so we'll understand better?
:-)
ASKER
Thanks sukumar_diya
That fixed that problem, and has caused another problem. As I only asked how to highlight a variable which you answered, I have opened another question with the new problem.
Caz
That fixed that problem, and has caused another problem. As I only asked how to highlight a variable which you answered, I have opened another question with the new problem.
Caz
string Word1 = "Word1";
HighlightWord = Regex.Replace(HighlightWor