Difference between revisions of "RemoveHTMLTags"
Jump to navigation
Jump to search
(Created page with 'string RemoveHTMLTags(string src) { integer is_HTML = 0; string result = ""; string s; integer i; for (i=0; i<llStringLength(src); i++) { s = llGetS...') |
m (<lsl> tag to <source>) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
string | {{LSL_Function | ||
|func=RemoveHTMLTags | |||
|mode=user | |||
|p1_type=string|p1_name=input_string|p1_desc=String to remove HTML tags from | |||
|return_type=string | |||
|return_text=with HTML ( or XML ) tags and newline characters removed. | |||
|func_footnote= | |||
See also: [[String]] | |||
|spec=<source lang="lsl2"> | |||
string remove_HTML_tags(string source) | |||
{ | { | ||
integer is_HTML = | integer is_HTML = FALSE; | ||
string | |||
string | string output; | ||
integer | string characterInSource; | ||
integer index; | |||
do | |||
{ | { | ||
characterInSource = llGetSubString(source, index, index); | |||
if (characterInSource == "<") | |||
is_HTML = | // { | ||
is_HTML = TRUE; | |||
// } | |||
if (!is_HTML && characterInSource != "\n") | |||
// { | |||
output += characterInSource; | |||
// } | |||
is_HTML = | |||
if (characterInSource == ">") | |||
// { | |||
is_HTML = FALSE; | |||
// } | |||
} | } | ||
return | while (++index < llStringLength(source)); | ||
return | |||
output; | |||
} | } | ||
</source> | |||
|caveats= | |||
*Text in elements that are not normally rendered will show up in the output (inline script tags, etc). | |||
|examples=<source lang="lsl2"> | |||
src = RemoveHTMLTags(src); | |||
</source> | |||
|helpers | |||
|notes | |||
|also | |||
|also_functions | |||
|also_articles | |||
|cat1=User-Defined_Functions | |||
|cat2=Examples | |||
|cat3 | |||
|cat4 | |||
}} |
Latest revision as of 15:34, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string RemoveHTMLTags( string input_string );Returns a string with HTML ( or XML ) tags and newline characters removed.
• string | input_string | – | String to remove HTML tags from |
See also: String
Specification
string remove_HTML_tags(string source)
{
integer is_HTML = FALSE;
string output;
string characterInSource;
integer index;
do
{
characterInSource = llGetSubString(source, index, index);
if (characterInSource == "<")
// {
is_HTML = TRUE;
// }
if (!is_HTML && characterInSource != "\n")
// {
output += characterInSource;
// }
if (characterInSource == ">")
// {
is_HTML = FALSE;
// }
}
while (++index < llStringLength(source));
return
output;
}
Caveats
- Text in elements that are not normally rendered will show up in the output (inline script tags, etc).
Examples
src = RemoveHTMLTags(src);