realbasic-nug
[Top] [All Lists]

Removing comments or empty lines in a string

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Removing comments or empty lines in a string
From: Eric de La Rochette <rblists@edlr.fr>
Date: Fri, 31 Oct 2008 22:36:12 +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
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
Hello there,

I have a string containing data lines, comment lines (the ones that start with a "#") or empty lines. And, when a valid data line starts with a "#", it is escaped like this "##" I need to clean this string in order to keep only the data lines. As I find RegEx a good way to do it, I started to code the removal of comment lines like this ( r is Dimed as RegEx, theRawData & theCleanData are strings ):

  r.SearchPattern = "^#[^#].*\n*" // I also tried "^#[^#].*[\n\r]*"
  r.ReplacementPattern = ""
  r.Options.ReplaceAllMatches = True

  theCleanData = r.Replace( theRawData )

So, this code removes the content of the comment line, but not the line itself. I thought that as the '\n*' is part of the search, it should have been replaced to...

As I need to also remove the empty lines, it shouldn't be such an issue. Unfortunately, I have no idea at all on how should look a search pattern that would find the empty lines... :-(

Any Advice ?

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>