[FIXED] Regex/split operator help please for /* comments */

50 views
Skip to first unread message

TW Tones

unread,
Aug 30, 2020, 8:04:29 PM8/30/20
to tiddl...@googlegroups.com
Hi,

Can someone please tell me the regexp so I can test for open and close comment in a line?

eg;
something1 something2 /* comment */ something3

I want to extract the content between /* and */ 

eg splitregexp[/*]rest[]splitregexp[*/]first[]

I can't define a macro containing /* as it is interpreted as a comment :(


Thanks in advance
Tones

Mark S.

unread,
Aug 30, 2020, 9:00:28 PM8/30/20
to TiddlyWiki
I'm not sure if you need regexpsplit for this. This worked for me:

<$vars split1="/*" split2="*/">

{{{ [{test}split<split1>nth[2]split<split2>nth[1]] }}}
</$vars>

where test contains

This is some text with an /* embedded comment */ in it.

If you really needed regexpsplit, then you would need to escape the asterisk and probably also the forward slash e.g. \/\* 

TW Tones

unread,
Aug 30, 2020, 10:02:23 PM8/30/20
to TiddlyWiki
Mark,

Thanks, this led to the solution, but I think it was my code, not the method, I had used define to define the open/close.

FYI: Here is it now working

<$vars open-comment="/*"
  close-comment="*/">
<$list filter="[[$:/PSaT/author-styles/stylesheet]get[text]splitregexp[\n]prefix[.]]" variable=definition>
<$set name=classname value={{{ [<definition>split[ ]removeprefix[.]] }}}>
<$set name=description value={{{ [<definition>split<open-comment>last[]split<close-comment>] }}}>
definition=<<definition>><br>
classname=<<classname>> description=<<description>><hr>
</$set></$set>
</$list>
</$vars>

This is while parsing a css file with lines including
.n { font-weight: normal;} /* Normal fontweight */

And the result is now
definition=.n { font-weight: normal;} /* Normal fontweight */
 classname
=n description=Normal fontweight

Thanks again

I am working on a .classname select-able editor Toolbar button.

Regards
Tones

Reply all
Reply to author
Forward
0 new messages