Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Text;
- namespace HTMLTagRemove
- {
- internal class Program
- {
- private const string INPUT_FILENAME = "termekek.csv";
- private const string OUTPUT_FILENAME = "termekek_result.csv";
- private static void Main()
- {
- string[] rows;
- using (var reader = new StreamReader(INPUT_FILENAME, Encoding.Default))
- {
- rows = reader.ReadToEnd().Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
- }
- rows = RemoveHtmlTags(rows);
- using (var writer = new StreamWriter(OUTPUT_FILENAME, false, Encoding.UTF8))
- {
- writer.Write(string.Join(";", rows));
- }
- Process.Start(OUTPUT_FILENAME);
- }
- private static string[] RemoveHtmlTags(string[] strings)
- {
- for (int i = 0; i < strings.Length; i++)
- {
- strings[i] = RemoveTagInString(strings[i]);
- }
- return strings;
- }
- public static string RemoveTagInString(string sourceString)
- {
- var charray = new char[sourceString.Length];
- int index = 0;
- bool isInside = false;
- foreach (char character in sourceString)
- {
- if (character == '<')
- {
- isInside = true;
- continue;
- }
- if (character == '>')
- {
- isInside = false;
- continue;
- }
- if (isInside) continue;
- charray[index] = character;
- index++;
- }
- return new string(charray, 0, index);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement