Reputation: 37
I'm struggling to find a solution to my small problem in VB.Net.
I basically have a string originally from an XML which I need to insert a new line (chr(13) after certain words.
So for example if my string is;
TAF AMD EGNM 171734Z 1718/1818 16010KT 9999 BKN018 TEMPO 1718/1803 8000 -RA BKN010 PROB30 TEMPO 1718/1724 4000 RADZ BKN006 PROB40 TEMPO 1800/1809 BKN005 PROB40 TEMPO 1809/1818 6000 SHRA BKN010 BKN020TCU BECMG 1810/1813 23010KT
I need it to look like this;
TAF AMD EGNM 171734Z 1718/1818 16010KT 9999 BKN018
TEMPO 1718/1803 8000 -RA BKN010
PROB30
TEMPO 1718/1724 4000 RADZ BKN006
PROB40
TEMPO 1800/1809 BKN005
PROB40
TEMPO 1809/1818 6000 SHRA BKN010 BKN020TCU
BECMG 1810/1813 23010KT
Keywords to split as you can see is 'TEMPO'
, 'PROB30'
, 'PROB40'
etc
Any ideas?
Upvotes: 0
Views: 943
Reputation: 10478
Try this:
Dim toReplace() = new String() {"TEMPO", "PROB30", "PROB40", (...)}
For Each word As String In toReplace
value = value.Replace(word, Environment.NewLine & word)
Next
Upvotes: 3