Why does regex replacement not remove empty lines?The purpose is to download web content, keep the visible content, and remove lines with only Spaces.
I use the following JSL but can't remove blank lines?
Thanks!
u = "https://www.jmp.com/support/help/zh-cn/17.2/jmp/jsl-terminology.shtml";
txt = Load Text File( u );
a = Length( txt );
t1 = Regex( txt, "<(.[^>]{0,})>", "", globalreplace );
t2 = Regex( t1, " ", "", globalreplace );
t2 = Regex( t2, "^( {0,})\!n", "", globalreplace );
t2 = Regex( t2, "\!n\!n", "", globalreplace );Basic Data Analysis and ModelingWindows回复: Why does regex replacement not remove empty lines?The same JSL can replace such empty lines, I do not know what went wrong?
Thanks!
txt =
"-->\!n\!n\!n\!nJSL Terminology\!n\!n\!n\!n\!n\!n\!nScripting Guide > Introduction to Writing JSL Scripts > JSL Terminology";
t1 = Regex( txt, "\!n\!n+", "", globalreplace );
回复: Why does regex replacement not remove empty lines?I used hex(t2) to see what was left in the string:
...0A0D0A0D0AE69CACE7BD91E7AB99E59CA8E590AFE794A8204A
61766153637269707420E79A84E68385E586B5E4B88BE69588E69E
9CE69C80E4BDB3E380820D0A0D0A0D0A0D0A0D0A0D0A0D0A0D0A"
The 0D0A pairs are CR LF pairs. \!n is JMP's escape for LF. I'd use this regex to match a run of any mix-and-match of CR and LF:
t2 = Regex( t2, "[\n\r]+", "", globalreplace );
Regex does not use the ! in the escape.
回复: Why does regex replacement not remove empty lines?...and typically, I'd replace runs of white space with
t2 = Regex( t1, "[ \n\r]+", " ", globalreplace );
(a space is also in the character set, and the replacement is a space) to keep the output a little more like the input, with the runs of white space compressed to a single space. (I removed the other t2= statements as well.)
Expression 2: Sum = 0; For( i = 1, i <= 10, i++, Sum += i; Sh
ow( i, Sum ); ); You can format your script in any way that you like. However, th
e script editor can also format your script for you. The Scripting Guide uses th
e script editor’s default formatting for capitalization, spaces, returns, tabs, and s
o on. See Work with the Script Editor for more information about using the scri
pt editor. Note: The only white space exception is two-character operators (suc
h as <= or ++). The operators cannot be separated by a space. 需要更多信
息?有问题?从 JMP 用户社区得到解答 (community.jmp.com). 本网站在
启用 JavaScript 的情况下效果最佳。 ";