Skip to content

Instantly share code, notes, and snippets.

@ugurhasar
Last active September 22, 2017 21:52
Show Gist options
  • Save ugurhasar/fba45e26775f7c1abbeb205e0002b9d9 to your computer and use it in GitHub Desktop.
Save ugurhasar/fba45e26775f7c1abbeb205e0002b9d9 to your computer and use it in GitHub Desktop.
C# ve JS'de HTML Etiketlerini Temizleme
public string CleanTags(string input)
{
char[] charArray = new char[input.Length];
int arrayIndex = 0;
bool inside = false;
for (int i = 0; i < input.Length; i++)
{
char tmp = input[i];
if (tmp == '<')
{
inside = true;
continue;
}
if (tmp == '>')
{
inside = false;
continue;
}
if (!inside)
{
charArray[arrayIndex] = tmp;
arrayIndex++;
}
}
return new string(charArray, 0, arrayIndex);
}
function cleanTags(input)
{
var array = [];
var inside = false;
for (i = 0; i < input.length; i++)
{
var let = input.charAt(i);
if (let == '<')
{
inside = true;
continue;
}
if (let == '>')
{
inside = false;
continue;
}
if (!inside)
array.push(let);
}
return array.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment