Look at the TextInputStream class. It has a ReadLine method.
Or ReadAll
if the file isnât that big.
https://documentation.xojo.com/api/files/textinputstream.html#textinputstream
You can, just add comments to your future self, or others, to get it faster.
Federico, you, by any chance, have multi-line constructs? Like:
/* remove */ valid text /* remove */
/* remove */ valid text /* remove
remove remove
remove */ valid text /* remove */
Yes, but thereâs nothing better than actually being able to read and understand your own code.
Itâs little used, but you can embed comments right in a pattern, e.g.:
(?U)(?# Make Ungreedy)/\*(?# Opening delimiter)[\s\S]*(?# Zero or more of anything)\*/(?# Closing delimiter)
Even better, you can split up complex patterns with whitespace using the (?x)
switch, e.g.:
(?x) # Free-space mode
(?U) # Ungreedy
/\* # Opening delimiter
[\s\S]* # Zero or more of anything
\*/ # Closing delimiter
Yes, there is. Being able to read any well documented code and documenting our own.
I dislike for example comments IN the pattern. I do prefer a clean pattern and proper comments outside saying what such pattern does.
I suppose a hybrid approach could be used:
Patter = ""
Pattern = Pattern + "(?U)" # Ungreedy
Pattern = Pattern + "/\*" # Opening delimiter
Pattern = Pattern + "[\s\S]*" # Zero or more of anything
Pattern = Pattern + "\*/" # Closing delimiter
Youâd have to add + EndOfLine
to each line though.
Sorry I didnât understand the question. However, I need to have what you wrote in the example.
Thanks for the code , itâs perfect. Simply and elegant.
GUYS I SOLVED.
Thanks everyone for the support.
Especially to Kem Tekinay, Chay Wesley. Their code is perfect and the two work great.
Thank you.
Great.
Please mark some post as âSolutionâ for future visitors.
Do you have remarks starting in one line, but not ending in the same line, but next one or further?
/* sdfgsdfg
sdfgsdf
*/
Or all them start and end in the same line
/* dgsdfgsfdg */
What I wrote WAS an example of such content.
That determines if you can read and apply the filter one line at a time or need to read all the content and apply it globally.
Why the pattern works without them.
Youâre right, I missed that you were no longer using the (?x)
switch.
You would have to switch to a valid comment char also. # doesnât work with Xojo. But strangely â which does, doesnât seem to work with the code box.
Disregarding the syntax error, I do prefer it solved all at once at compile time as a constant.
Const Pattern As String = "(?U)" _ // Ungreedy
+ "/\*" _ // Opening delimiter
+ "[\s\S]*" _ // Zero or more of anything
+ "\*/" // Closing delimiter
if only _ looked that good in the IDE, I would use it more.
It can look good enough
Or