¿Cómo se puede usar la sustitución de expresiones regulares <*>?Cómo usar expresiones regulares para reemplazar el texto de dt[1,"A"] con pestañas para cada <*>. Obtiene el resultado de varias columnas en la fila 2.

¡Gracias!
abc<AHREF>897"id="s897"</AHREF>
secuencias de comandosRe: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?ignore los comentarios de 0,5 segundos, # enlaces en el JSL. Ejecute su propia prueba.
Los comentarios se estropean rápidamente, ¡especialmente cuando se copia/pega!
Re: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?/*
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: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?Quiero usar JSL a través de JMP directamente para obtener el título de la página y la lista de enlaces.
Por ejemplo: esta página web de la comunidad JMP,

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: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?No estoy seguro de si todavía estás haciendo una pregunta. Si todavía está tratando de hacer que algo funcione, necesitaría saber qué está tratando de hacer.
¿Está intentando usar un editor de texto para reformatear el archivo en un archivo delimitado por tabuladores que JMP pueda leer?
Re: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?Gracias Craig!
Estoy usando la sustitución regular de "EmEditor"
<(.[^>]{0,})>Guion:
document.selection.Replace("<(.[^>]{0,})>","\\t",eeReplaceAll | eeFindReplaceRegExp,eeExFindSeparateCRLF);Re: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?He estado escribiendo código C últimamente. C usa \" para escapar de un " pero JSL usa \!" para escapar de un ".
Los tres del interior de la cadena " necesitan el escape JSL.
Re: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?Te dije que no estaba probado... uso
\!"
por los fugados"
Re: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?Gracias Craig!
Intenté la operación, JSL no se pudo ejecutar.


Re: ¿Cómo puedo usar la sustitución de expresiones regulares <*>?Creo que quieres fórmulas separadas para las columnas b, c, ...
La fórmula de la columna b debe extraer parte de la cadena href.
La fórmula de la columna c debe extraer parte de la cadena de identificación.
Las fórmulas exactas pueden ser bastante simples si los datos tienen la misma forma en cada fila. Por ejemplo, si siempre hay un número justo antes de para la columna b, (sigue el código no probado)
regex(a, "(\d+)", "\1")
Podría funcionar. Rompiendo ese patrón:
- (\d+) - los paréntesis crean el grupo de captura \1, \d es un dígito, + es uno o más
- - texto literal que debe seguir a los números
- "\1" - inserta el grupo de captura 1 en el resultado
De manera similar, si el texto de la columna c siempre se identifica con id=,
regex(a,"id=\"[^\"]*\"")
Podría funcionar.
Este patrón usa \" Tres lugares para representar una comilla dentro de una cadena JSL rodeada de comillas. Si eliminamos las comillas externas y eliminamos las internas, la cadena que ve la expresión regular es<STRONG> identificación="[^"]*"</STRONG> que se descompone en
- juego identificación = y el "
- [^"] es una clase de carácter que coincide con cualquier carácter que NO sea un "
- * significa cero o más de los no- " caracteres
- seguido por "
Un análisis simple como este generalmente funcionará en datos que se comporten bien. En el caso general, es posible que necesite patrones más complicados (si pudiera haber otra cadena id=, etc.).