Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
Questionstoring data from textbox into different files Pin
troubled one11-Sep-07 4:06
troubled one11-Sep-07 4:06 
AnswerRe: storing data from textbox into different files Pin
Ermak8611-Sep-07 4:08
Ermak8611-Sep-07 4:08 
GeneralRe: storing data from textbox into different files Pin
troubled one11-Sep-07 16:06
troubled one11-Sep-07 16:06 
QuestionIs there any objects for Mins and Seconds. Pin
John.L.Ponratnam11-Sep-07 3:34
John.L.Ponratnam11-Sep-07 3:34 
AnswerRe: Is there any objects for Mins and Seconds. Pin
pmarfleet11-Sep-07 3:39
pmarfleet11-Sep-07 3:39 
AnswerRe: Is there any objects for Mins and Seconds. Pin
\laddie11-Sep-07 5:50
\laddie11-Sep-07 5:50 
Questionhow we can control printer tray with csharp? [modified] Pin
mohammadser11-Sep-07 3:31
mohammadser11-Sep-07 3:31 
AnswerRe: how we can control printer tray with csharp? Pin
martin_hughes11-Sep-07 10:39
martin_hughes11-Sep-07 10:39 
Questionget only string as input Pin
prasadbuddhika11-Sep-07 2:45
prasadbuddhika11-Sep-07 2:45 
AnswerRe: get only string as input Pin
Christian Graus11-Sep-07 2:46
protectorChristian Graus11-Sep-07 2:46 
QuestionProcess hangs with RedirectStandardOutput Pin
liqnit11-Sep-07 2:39
liqnit11-Sep-07 2:39 
AnswerRe: Process hangs with RedirectStandardOutput Pin
Judah Gabriel Himango11-Sep-07 5:12
sponsorJudah Gabriel Himango11-Sep-07 5:12 
GeneralRe: Process hangs with RedirectStandardOutput Pin
liqnit11-Sep-07 18:21
liqnit11-Sep-07 18:21 
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 

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.