使用 AppMeasurement 安装此插件

在实例化(使用 s_gi)Analytics 跟踪对象后,将以下代码复制并粘贴到 AppMeasurement 文件中的任意位置。 在您的实施中保留代码的注释和版本号可帮助 Adobe 对任何潜在问题进行疑难解答。

/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: cleanStr v2.0 (No Prerequisites Required) */
function cleanStr(str){var a=str;if("-v"===a)return{plugin:"cleanStr",version:"2.0"};a:{if("undefined"!==typeof window.s_c_il){var b=0;for(var c;b<window.s_c_il.length;b++)if(c=window.s_c_il[b],c._c&&"s_c"===c._c){b=c;break a}}b=void 0}"undefined"!==typeof b&&(b.contextData.cleanStr="2.0");if("string"===typeof a){a=a.replace(/<\/?[^>]+(>|$)/g,"");a=a.trim();a=a.replace(/[\u2018\u2019\u201A]/g,"'");a=a.replace(/\t+/g,"");for(a=a.replace(/[\n\r]/g," ");-1<a.indexOf("  ");)a=a.replace(/\s\s/g," ");return a}return""}
/******************************************** END CODE TO DEPLOY ********************************************/

使用此插件

cleanStr 函数使用以下参数:

  • str(必需,字符串):用于清理 HTML 编码、额外空格、制表符或其他不必要字符的值。

该函数会返回 str 参数的值,并删除所有不必要的字符。

示例

// Returns the value "this is a messystring". Note that both tabs and extra spaces are present in the original string.
// Multiple spaces are reduced to one, while tabs are omitted entirely.
s.eVar1 = "  this  is a      messy  string    ";
s.eVar1 = cleanStr(s.eVar1)

// This function call does not do anything because the code does not assign the returned value to a variable.
s.eVar1 = "  this  is a      messy  string    ";
cleanStr(s.eVar1);

版本历史记录

2.0(2021 年 3 月 19 日)

  • 以上下文数据形式添加了版本号。

1.0(2018 年 4 月 15 日)

  • 第一版。
已自动翻译
使用语言选择器查看此页面的英文版本。
翻译有帮助吗?

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.