Project oriented apps

Discussion in 'Web Design and Development' started by memco, Oct 23, 2008.

  1. memco macrumors 6502

    Joined:
    May 1, 2008
    #1
    I currently use Smultron, which is a very nice free editor, but I'm finding it chokes on having more than 15 or so files open at once. I'm curious if any alternatives handle opening and/or working with a large number of files better than Smultron. Is it just my poor old 1.67ghz PB that's too weak, or is it the software, or both?
     
  2. memco thread starter macrumors 6502

    Joined:
    May 1, 2008
    #3
    Thanks AW, both seem to handle things better. Sadly though, my regexp isn't working on either Tm or TW.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    Can you explain? Might be able to advise.
     
  4. memco thread starter macrumors 6502

    Joined:
    May 1, 2008
    #5
    My regexp is this:
    Code:
    [^]*.*?<(title*)\b[^>]*>(.*?)</\1>[^]*.*?"body"\s-->([^]*.*?)<!--\sInstanceEndEditable\s-->(?:.*?)[^]*.*?
    Smultron was able to process that and find matches, but TW says "missing terminating ] for character class," and TM doesn't do anything at all. I'm sure it's not entirely correct, and even more–so when there doesn't seem to be an option for multiline matching in either.
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    I remember that regex. TW I believe will do multiline if the regex is set for it, which I believe your does. Some of your regex I'm unsure of though. Namely these pieces:
    Code:
    title*
    "body"
    (Edit: Never mind, figured them out after spotting the corresponding pieces in the txt file.)

    TW uses grep to power the regular expressions, whereas Smultron uses ICU, so it's possible they interpret the regex differently. When I put your regex in BBEdit's grep find it has color coding and shows it's having problems with the [^] parts. You can alternatively try [(?:\n|\r\n|\r)] in its place. I know I'm the one who suggested the [^] in the older thread, but I was somewhat confused on why it worked. ha ha.

    Edit: I tried this regex out on your services.txt file from your last thread on this topic.
    Code:
    [(?:\n|\r\n|\r)]*.*?<(title*)\b[^>]*>(.*?)</\1>[^^]*.*?"body"\s-->([^^]*.*?)<!--\sInstanceEndEditable\s-->(?:.*?)[^^]*.*?
    I tried using the (?:\n|\r\n|\r) bit in all of the spots, but it just ended up highlighting the whole document, but it may have still captured the pieces you wanted.
     
  6. memco thread starter macrumors 6502

    Joined:
    May 1, 2008
    #7
    Yes, I know it's strange that the whole document is highlighted, but that is in fact what I want. That regex grabs the title and the body text (the reason "body" is used is because it's scanning a DW template where the actual content can only be identified in a comment with the text "body"). I then do a replace preserving the title and body and placing them correctly within the new template.

    Thanks again for all your help.
     
  7. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #8
    I think I may have found a better regex than what I gave.
    Code:
    .*?<(title*)\b[^>]*>(.*?)</\1>[\s\S]*"body"\s-->([\s\S]*)<!--\sInstanceEndEditable\s-->(?:.*?)
    It won't highlight everything, but still captures all the parts you're after, and I feel better about its syntax.
     
  8. memco thread starter macrumors 6502

    Joined:
    May 1, 2008
    #9
    Angelwatt, I've found that the regexp you came up with isn't working right. I haven't yet had a chance to look at it myself, to make sure the grouping is right, but I'm attaching two samples, in hopes that you can see what I'm going for. The whole point of the regexp is to capture everything and replace it all–but in doing so, there's a few pieces I want to put into the replacement text.

    Here's the (old) regexp and what it should like when replaced:

    Code:
    [^]*.*?<(title*)\b[^>]*>(.*?)</\1>[^]*.*?"body"\s-->([^]*.*?)<!--\sInstanceEndEditable\s-->(?:.*?)[^]*.*?
    
    <%
    	PageTitle = "$2"
        PageDesc = ""
    %>
    <!-- #include virtual="/asptemp/pstudentheader.asp" -->
    $3
    <!-- #include virtual="/asptemp/pstudentfooter.asp" -->
    
    About is what it should like, airports is what it returns.
     

    Attached Files:

  9. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #10
    I tested the regex I gave on the airports.txt file and checked what each of the groupings were catching and it all looked fine. I was testing with BBEdit 9. Not sure if you're using an app to run the regex or ASP. One thing not being mentioned specifically with the regex is that it needs to be case insensitive, which screw me up for a moment. Let me know how you're using the regex.

    Though, now thinking about it, as you weren't completely clear on what was going wrong, if all text in the file needs to be captured, then the regex needs a small tweak at the beginning and end. Below grabs all text on the page then will have the following groupings:

    $1: "title" of the title tag
    $2: Text inside the title tag
    $3: Everything between "InstanceBeginEditable name="body" -->" and "<!-- InstanceEndEditable --> </div>"

    Updated Regex
    Code:
    [\s\S]*<(title)\b[^>]*>(.*?)</\1>[\s\S]*"body"\s-->([\s\S]*)<!--\sInstanceEndEditable\s-->[\s\S]*
     
  10. memco thread starter macrumors 6502

    Joined:
    May 1, 2008
    #11
    Angelwatt, that's a nice regexp–it's simple, and works. I appreciate the help. I'm pretty sure I'm gonna spring for Textmate now that I've had a chance, and a reason, to use it.
     
  11. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #12
    Not a problem, glad we got it figured out.
     

Share This Page