正規表現置換<*>はどのように使用できますか?正規表現を使用してdt[1、 "A"]のテキストを各<*>のタブに置き換える方法。これにより、行2に複数列の結果が得られます。

ありがとう!
abc<AHREF>897"id="s897"</AHREF>
スクリプティングRe:正規表現置換<*>はどのように使用できますか?.5秒を無視し、#JSLのコメントをリンクします。 独自のテストを実行します。
特にコピー/貼り付けの場合、コメントはすぐに悪くなります。
Re:正規表現置換<*>はどのように使用できますか?/*
THIS IS NOT AN HTML PARSER
HTML parsers are hard to write. There are better ways.
Neither of these JSL ideas can properly skip comments or
many other HTML tags that should be skipped. They will
find things they shouldn't and miss other things they
should find. They've only been minimally tested on one site.
This code is presented as "how can I use contains() vs patmatch()
to efficiently work through a large string looking for something?"
The second example is FIVE TIMES FASTER and a LITTLE MORE ACCURATE.
The third example uses text explorer to grab links. I don't think
there is a pre-existing regex for the link text descriptions. It works
very similar to this code; it is NOT an HTML parser either.
If you can use python, you might want to investigate "beautiful soup".
I've not used it, but believe it addresses the "hard to write" issue.
*/
u = "https://community.jmp.com/t5/Discussions/bd-p/discussions";
txt = Load Text File( u );
// a link on a page has at least two parts:
// the URL and some descriptive text.
// <A ...="" href="https://community.jmp.com/url" ...="" target="_blank" rel="nofollow noopener noreferrer"> descripton </A>
// p1 p4 p5
// to parse ALL the links on a page, you'll want
// some sort of loop. There are many ways to
// write that loop; here are two choices
// using contains and regex. "<A>", p1 + 3 ); // find the end of the opening tag
p5 = Contains( txt, "</A>", p4 + 1 ); // find the ending tag
if( p5 > p4, // as long as the end is not zero, we found one, see break() below
desc = Substr( txt, p4 + 1, p5 - p4 - 1 ); // the visible link description. Images can be here too.
desc = Regex( desc, "<[^>]*>", "", globalreplace ); // remove span, image, etc tags
linktext = Substr( txt, p1, p4 - p1 + 1 ); // <A href="https://community.jmp.com/" target="_blank">
hreftext = Regex( linktext, "href\s*=\s*(\!"|')(.*?)(\1)", "\2" );// use regex to get the href value
if( !Is Missing( hreftext ), // sometimes there isn't one
dt << addrows( 1 );//
irow = N Rows( dt );//
dt:link[irow] = hreftext;//
dt:description[irow] = desc; //
);//
, // else
Break() // no more end tags. there is maybe a mess of javascript.
);//
pos = Max( pos, p5 + 3 ); // advance past the one just found
Wait( 0 );
);
stoptime = Tick Seconds();
dt << endDataUpdate;
Show( stoptime - starttime ); // .5 sec, 127 links
// using pattern matching and regex
// this is about 5X faster and skips over the garbage in the <SCRIPT> sections
// two patterns, one for &amp;amp;amp;lt;a&amp;amp;amp;gt; links and one for &amp;amp;amp;lt;script&amp;amp;amp;gt; to skip over
linkpat = "&amp;amp;amp;lt;a " + Pat Break( "&amp;amp;amp;gt;" ) &amp;amp;amp;gt;&amp;amp;amp;gt; linktext + "&amp;amp;amp;gt;" + Pat Arb() &amp;amp;amp;gt;&amp;amp;amp;gt; desctext + "&amp;amp;amp;lt;/a&amp;amp;amp;gt;";
scriptpat = "&amp;amp;amp;lt;script" + Pat Break( "&amp;amp;amp;gt;" ) + "&amp;amp;amp;gt;" + Pat Arb() + "</SCRIPT>";
dt = New Table( "patmatch", New Column( "description", Character, "Nominal" ), New Column( "link", Character, "Nominal" ) );
Wait( .1 );
dt << beginDataUpdate;
startTime = Tick Seconds();
rc = patmatch( txt,
patrepeat( // repeat the pattern until no more
(linkpat + pattest(// run some JSL for the linkpat...
desc = Regex( desctext, "<[^>]*>", "", globalreplace ); // remove span, etc tags
hreftext = Regex( linktext, "href\s*=\s*(\!"|')(.*?)(\1)", "\2" );//
if( !Is Missing( hreftext ), //
dt << addrows( 1 );//
irow = N Rows( dt );//
dt:link[irow] = hreftext;//
dt:description[irow] = desc; //
);//
1; // pattest needs this to succeed
)) | scriptpat /* maybe skip a script */ | /* maybe skip to the next tag */ (Pat Len( 1 ) + Pat Break( "<" ))
),
NULL,IGNORECASE
);
stoptime = Tick Seconds();
dt << endDataUpdate;
Show( stoptime - starttime ); // .5 sec, 128 links
Show( rc ); // should be 1, not 0
///////////////////////////////////////
// text explorer can also do this:
dt=New Table( "textexplorer",
Add Rows( 1 ),
New Column( "text", Character, "Nominal", Set Values( evallist({txt}) ) )
);
dt<<TEXT explorer=""></TEXT></A>Re:正規表現置換<*>はどのように使用できますか?JMP経由でJSLを直接使用して、ページのタイトルとリンクリストを取得したいと思います。
例:このJMPコミュニティWebページ、

u="https://community.jmp.com/t5/Discussions/bd-p/discussions";txt=loadtextfile(u);
t1="";offset=Contains(txt,t1);
If(offset,txt=SubStr(txt,offset+4,Length(txt)));
t2="";offset=Contains(txt,t2,-1);
If(offset,txt=SubStr(txt,1,offset-1));
txt=Substitute(txt," ","","message">","","Discussions/","Discussions/>");
txt=Substitute(txt,"<(.[^>]{0,})>","","\!n","","\!r","");
Re:正規表現置換<*>はどのように使用できますか?あなたがまだ質問をしているのかどうかはわかりません。 あなたがまだ何かを動かそうとしているのなら、私はあなたが何をしようとしているのかを知る必要があるでしょう。
テキストエディタを使用して、ファイルをJMPが読み取れるタブ区切りファイルに再フォーマットしようとしていますか?
Re:正規表現置換<*>はどのように使用できますか?クレイジありがとう!
「EmEditor」の通常の置換を使用しています
<(.[^>]{0,})>脚本:
document.selection.Replace("<(.[^>]{0,})>","\\t",eeReplaceAll | eeFindReplaceRegExp,eeExFindSeparateCRLF);Re:正規表現置換<*>はどのように使用できますか?最近Cコードを書いています。 Cは\を使用して"をエスケープしますが、JSLは\!"を使用して"をエスケープします。
文字列内の3つすべて"にはJSLエスケープが必要です。
Re:正規表現置換<*>はどのように使用できますか?それはテストされていないとあなたに言いました...使用
\!」
逃げた者のために」
Re:正規表現置換<*>はどのように使用できますか?クレイジありがとう!
操作を試みましたが、JSLが実行できませんでした。


Re:正規表現置換<*>はどのように使用できますか?列b、c、...に別々の数式が必要だと思います。
列bの式は、href文字列の一部を抽出する必要があります。
列cの式は、id文字列の一部を抽出する必要があります。
データがすべての行で同じ形状である場合、正確な式は非常に単純な場合があります。 たとえば、列bのの直前に常に数字がある場合(テストされていないコードが続きます)
regex(a, "(\d+)", "\1")
うまくいくかもしれません。 そのパターンを分解する:
- (\ d +)-親は\ 1キャプチャグループを作成し、\ dは数字、+は1つ以上です
- -数字の後に続く必要があるリテラルテキスト
- "\1"-キャプチャグループ1を結果に挿入します
同様に、列cのテキストが常にid =で識別される場合、
regex(a,"id=\"[^\"]*\"")
うまくいくかもしれません。
このパターンは\"を使用します三場所引用符で囲まれたJSL文字列内の引用符を表します。 外側の引用符を削除して内側の引用符をエスケープ解除すると、正規表現が認識する文字列は次のようになります。<STRONG> id = "[^"] * "</STRONG>に分解します
- マッチid =そしてその「」
- [^ "]は、ではない任意の文字に一致する文字クラスです「」
- *ゼロ以上のないことを意味します- 「」文字
- に続く「」
このような単純な解析は、通常、正常に動作するデータで機能します。 一般的なケースでは、より複雑なパターンが必要になる場合があります(別のid =文字列がある場合など)。