Is there any page shows examples and practices of regexp in Tiddlywiki
(1) show what regex do & how;(2) allows interactive testing against test data to improve one's regex;(3) illustrates how you use regex in TW filters.
\define html-tags() regex filter
<$set name=html-tag value="article">
<$list filter="[[tiddlername]subfilter<html-tags>]">
</$list>
</$set>
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/43b26b25-3d08-4c7f-9ef4-ea4daacfd50e%40googlegroups.com.
You are aware I do not want so much to parse it as locate the content between matching tags.
Its intention is to access content delimited by html tags inside the text content.
Perhaps we could use it to retrieve items between the section div tags or all instances of text between the li tags.
Regards
Tony
Regards
Tony
There's an old trope in software that one should never use regexps to parse HTML:So, while I'd be happy to see general regexp support improved in TW5, I don't think it's appropriate to specifically shape that support for the task of parsing HTML.Of course, TW5 already includes an HTML parser so perhaps the best approach might be to explore how to make that functionality be more usefully exposed to wikitext.
<$vars realchars="[^\s]+">
<$list filter="[{test}splitregexp[\n]join[ ]splitregexp[<li>]butfirst[1]splitregexp[</li>]butlast[1]regexp<realchars>]">
</$list>
</$vars>
More text here
<li>line 3</li>
<li>line 2</li>
<li>line 1</li>
More text there
<li>line 3</li>
<li>line 2</li>
<li>line 1</li>
<li style="something">line 1</li>
line 1
All we have is regex.
It would be great to have some other tool for extracting actual DOM-like structures the way you could with TW classic. But we don't have it.
Actually, the tool we have for regexp is also a bit lacking. There's no tool for directly lifting desired target text.
[{test}splitregexp[\n]join[ ]splitregexp[<li.*?>]butfirst[1]splitregexp[</li>]butlast[1]regexp<realchars>]
Thanks!
zfdtshwfthf
<li>Content</li>
sfghn
<li>Content2</li>
sfghsfgh
<li>Content3</li>
sxgfhfgsdh
Content
Content2
Content3
\define output()
<$vars realchars="[^\s]+">
<
$list
filter="[{test data}splitregexp[\n]join[ ]splitregexp[<li.*?>]butfirst[1]splitregexp[</li>]butlast[1]regexp<realchars>addprefix[<li>]addsuffix[</li>]]">
</$list>
</$vars>
\end
<$wikify name=result text="<<output>>">
<<result>>
</$wikify>
In this case I was extracting all list items from a more complex html source then relisting the items.
The result is clean with only list items.
Regards
Tony