realbasic-nug
[Top] [All Lists]

Re: Removing comments or empty lines in a string

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: Removing comments or empty lines in a string
From: Eric de La Rochette <rblists@edlr.fr>
Date: Fri, 31 Oct 2008 23:46:58 +0000
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <8543B23A-961E-4931-96FD-C6F952594379@declareSub.com>
References: <7A56BED8-B975-415B-BD9D-7395F9BC3DF8@edlr.fr> <8543B23A-961E-4931-96FD-C6F952594379@declareSub.com>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com

Le 31 oct. 08 à 23:12, Charles Yeomans a écrit :

I'm not sure that RegEx is not the way to do it.  But if you must,

I don't have to, but I find it interesting to do it with RegEx in order to improve my knowledge on this area.

r.SearchPattern = "#[^#]*\n"

will work for A Mac app reading text with Mac line endings. My testing in the course of drafting this reply suggests that getting this to work cross-platform is rather tricky.

Actually, your note about the cross-platform potential issue, help me to find the solution:

r.SearchPattern = "^#[^#][^\x0A\x0D]*[\x0A\x0D]+"

That's for the comment line, and it avoids the use of the greedy dot. Besides, it gave me the solutions for the empty lines:

r.SearchPattern = "^[\x0A\x0D]+"

After a few tests, it appears to be cross-platform at lesat for the CR, LF and CRLF ends of line.

Thanks Charles for the inspiration.

Eric.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>