I have a string like this:
font-family:Arial;font-size:10px;color:green;
I would like to retrieve the string like this:
Arial;10px;green
How do I accomplish this ?
Printable View
I have a string like this:
font-family:Arial;font-size:10px;color:green;
I would like to retrieve the string like this:
Arial;10px;green
How do I accomplish this ?
Do you use regular expressions or would string functions be better?
Hello,
Am I right in saying that you are parsing HTML that you are getting from "somewhere"?
If so, you might want to take a look at the HTMLAgilityPack:
http://htmlagilitypack.codeplex.com/
Which I am fairly sure has methods for getting at this data.
Gary
You can use Regular expressions for your purpose. This is possible both ways - javascript as well as server side asp.net code, since both support Regular experessions in one form or the other.
The following Regex expression will help get you the relevent parts:
Here's the strategy:Code:(?<=:).+?(?=;)
Use the regex expression I provided above to get the required parts. You will obviously get them in separate groups/sub-groups. All you need to do after that is to join/concatenate them with a semi-colon in between.
Let me know if you need some sample code and I'll try to quickly construct one.