473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GetBoldWords()

This example that Mun give me works fine if theres only one set of
bold tags <b>ddf</b> but it would fail if there are more than one
input = "<b>ddf</b><b>dddfs</b>"
output = "ddf</b><b>dddfs"

is there a way to save each word in bold into an array?

Thanks,
aaron
-------------------
Here's my original post
I need a function in c# that finds and outputs word in bold.
string input = "<b>Hello my name</b> is John"

public string GetBoldWords()
{
//the function
return s // s = "Hello my name"
}

thanks
------------------------------------------------- You could use the regular expression - <b>(.*)</b>.

public string GetBoldWords(string somestring)
{
string foundMatch = string.Empty;
Regex RegExObj= new Regex("<b>(.*)</b>", RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Match MatchObj =
RegExObj.Match(somestring);
if (MatchObj.Success) foundMatch = MatchObj.Groups[1].Value;
return foundMatch;
}
Hope this helps,

Mun

Nov 15 '05 #1
1 1126
Just a shot in the dark but try something like this.
Embed the string you want to parse into an xml document(i.e. <parsethis>
..... </parsethis>)
Then use the System.XML namespace to help you parse it as an xml document
looking for the <b> tags.
You can use XMLTextReader or XMLDocument for this.

Hope this helps
Cheers,
Paul
"Aaron" <ku*****@yahoo.com> wrote in message
news:b4**************************@posting.google.c om...
This example that Mun give me works fine if theres only one set of
bold tags <b>ddf</b> but it would fail if there are more than one
input = "<b>ddf</b><b>dddfs</b>"
output = "ddf</b><b>dddfs"

is there a way to save each word in bold into an array?

Thanks,
aaron
-------------------
Here's my original post
I need a function in c# that finds and outputs word in bold.
string input = "<b>Hello my name</b> is John"

public string GetBoldWords()
{
//the function
return s // s = "Hello my name"
}

thanks

-------------------------------------------------
You could use the regular expression - <b>(.*)</b>.

public string GetBoldWords(string somestring)
{
string foundMatch = string.Empty;
Regex RegExObj= new Regex("<b>(.*)</b>", RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Match MatchObj =
RegExObj.Match(somestring);
if (MatchObj.Success) foundMatch = MatchObj.Groups[1].Value;
return foundMatch;
}
Hope this helps,

Mun

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aaron | last post by:
I need a function in c# that finds and outputs word in bold. string input = "<b>Hello my name</b> is John" public string GetBoldWords() { //the function return s // s = "Hello my name" }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.