Link to home
Start Free TrialLog in
Avatar of amaru96
amaru96

asked on

VB.NET How to strip unwanted values from a string?

Hi guys, I need to do some string manipulation but not really sure how to go about it.

I have a string that is read from a database that typically looks like the below:
Windows Server 2003, Windows Server 2008
Windows 7
Windows Server 2003, junk, more junk, Windows Server 2008, junk, Windows Server 2012
Windows 7, junk, Windows 8

What I'm trying to do is to have it look at the values between the commas and remove it if it doesn't equal one of the below:
Windows Server 2003
Windows Server 2008
Windows Server 2008 R2
Windows Server 2012
Windows Server 2012 R2
Windows 7
Windows 8

Below are some examples of what I'm trying to achieve.

Original string
Windows Server 2003, junk, more junk, Windows Server 2008, junk, Windows Server 2012

Clean string
Windows Server 2003, Windows Server 2008, Windows Server 2012

Original string
Windows 7, junk

Clean string
Windows 7


So "junk" is anything that doesn't equal one of those operating systems listed above.


How would I go about doing this?
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amaru96
amaru96

ASKER

Thanks guys, I can work with those.