Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
QuestionChecked change event Pin
M. J. Jaya Chitra11-Sep-07 2:31
M. J. Jaya Chitra11-Sep-07 2:31 
AnswerRe: Checked change event Pin
Christian Graus11-Sep-07 2:45
protectorChristian Graus11-Sep-07 2:45 
GeneralRe: Checked change event Pin
M. J. Jaya Chitra11-Sep-07 2:57
M. J. Jaya Chitra11-Sep-07 2:57 
GeneralRe: Checked change event Pin
Ermak8611-Sep-07 4:04
Ermak8611-Sep-07 4:04 
GeneralRe: Checked change event Pin
Mairaaj Khan11-Sep-07 12:06
professionalMairaaj Khan11-Sep-07 12:06 
QuestionRegular expression inside a textbox Pin
segusmitha11-Sep-07 2:30
segusmitha11-Sep-07 2:30 
AnswerRe: Regular expression inside a textbox Pin
snorkie11-Sep-07 4:36
professionalsnorkie11-Sep-07 4:36 
GeneralRe: Regular expression inside a textbox Pin
segusmitha11-Sep-07 18:33
segusmitha11-Sep-07 18:33 
Hi Hogan,

Thanks for your reply,

Basically what am i trying to do is., iam returning few keywords from my backend and if my aspx page has those matching keywords i will highligt those words alone using some class. but the problem is its applying the class for the text inside the textbox also.

Please see the code below.

I have a user control., where i have this code
//this is a c# code
strCode = HighlightKeywords("Hemoglobin", strCode);

here i am calling a method which will return me strCode itself., the strCode will contain a innerhtml of a span and in that span
//This is how my span looks
Alpha-1-fetoprotein Hemoglobin



// now when the HighlightKeywords() method is called, using that method i should highlight that "Hemoglobin" word for the text inside span but not for the text inside my textbox.

so now the code for HighlightKeywords()
private static string HighlightKeywords(string keywords, string text)
{
// Swap out the ,<space> for pipes and add the braces
Regex r = new Regex(@", ?");
keywords = "(" + r.Replace(keywords, @"|") + ")";

// Get ready to replace the keywords
r = new Regex(keywords, RegexOptions.Singleline | RegexOptions.IgnoreCase);
// Do the replace
text = r.Replace(text, new MatchEvaluator(MatchEval));
/*the above code would have replaced the whole span's inner html text where ever Hemoglobin is there it would have replaced using that MatchEval eval method*/
-- now iam see whether there is any textbox if there is a text box then remove that span class='h1' text placed in that textbox.

Regex re = new Regex("(<[^>]*?)"+keywords+"<\\/span>(.*?>)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
text = re.Replace(text, "$1$2$3") ;

return text ;
}
private static string MatchEval(Match match)
{
if (match.Groups[1].Success)
{
return "" + match.ToString() + "";

}

return ""; //no match
}

// its also replacing that "haemoglobin" inside that text box back to haemoglobin. but for only first occurance and not doing for the sencond and third occurance. am i missing anything., i have pasted the whole code. Pls let me know if iam doing something wrong.,



Smitha Smile | :)

QuestionHiding main form upon load Pin
Justin Perez11-Sep-07 2:24
Justin Perez11-Sep-07 2:24 
AnswerRe: Hiding main form upon load Pin
Giorgi Dalakishvili11-Sep-07 2:39
mentorGiorgi Dalakishvili11-Sep-07 2:39 
GeneralRe: Hiding main form upon load Pin
Justin Perez11-Sep-07 2:53
Justin Perez11-Sep-07 2:53 
GeneralRe: Hiding main form upon load Pin
Giorgi Dalakishvili11-Sep-07 2:58
mentorGiorgi Dalakishvili11-Sep-07 2:58 
GeneralRe: Hiding main form upon load Pin
Justin Perez11-Sep-07 3:02
Justin Perez11-Sep-07 3:02 
GeneralRe: Hiding main form upon load Pin
Ermak8611-Sep-07 3:04
Ermak8611-Sep-07 3:04 
GeneralRe: Hiding main form upon load Pin
Giorgi Dalakishvili11-Sep-07 3:05
mentorGiorgi Dalakishvili11-Sep-07 3:05 
GeneralRe: Hiding main form upon load Pin
Justin Perez11-Sep-07 3:11
Justin Perez11-Sep-07 3:11 
GeneralRe: Hiding main form upon load Pin
Giorgi Dalakishvili11-Sep-07 3:17
mentorGiorgi Dalakishvili11-Sep-07 3:17 
GeneralRe: Hiding main form upon load Pin
Justin Perez11-Sep-07 3:21
Justin Perez11-Sep-07 3:21 
GeneralRe: Hiding main form upon load Pin
Giorgi Dalakishvili11-Sep-07 3:26
mentorGiorgi Dalakishvili11-Sep-07 3:26 
JokeRe: internet speed Pin
Ed.Poore11-Sep-07 2:53
Ed.Poore11-Sep-07 2:53 
QuestionActiveX Exception Pin
DeepOceans11-Sep-07 2:12
DeepOceans11-Sep-07 2:12 
AnswerRe: ActiveX Exception Pin
Justin Perez11-Sep-07 2:27
Justin Perez11-Sep-07 2:27 
GeneralRe: ActiveX Exception Pin
DeepOceans11-Sep-07 21:43
DeepOceans11-Sep-07 21:43 
Questionhow do i delete lines from .txt file? "Urgent!" Pin
andredani11-Sep-07 2:04
andredani11-Sep-07 2:04 
AnswerRe: how do i delete lines from .txt file? "Urgent!" Pin
Christian Wulff11-Sep-07 2:21
Christian Wulff11-Sep-07 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.