homepage Welcome to WebmasterWorld Guest from 54.166.228.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
Forum Library, Charter, Moderator: open

WYSIWYG and Text Code Editors Forum

    
NoteTab Pro (or regex text editor) to find code sections to replace
analogous to Library Items in DreamWeaver... is it possible?
Robert Charlton




msg:3311817
 6:35 pm on Apr 15, 2007 (gmt 0)

I'd like to be able to set up NoteTab Pro to do global search and replacement of sections of code in a group of documents. The sections would be identified by unique starting and ending text strings, but what's in between might vary. This would allow global replacement of sections, but wouldn't be broken by manual change in specific documents. (I understand that these manual changes would be lost in the replacements). Is it possible?

I haven't gotten into either regular expressions or Clip Programming with NTP, but I'm thinking I'd have to use one or the other to accomplish this, if it can be done.

My approach will be to identify a starting string and an ending string, and set up a routine to globally search and replace these and everything in between them. If doable, this would effectively work like the Library Items in DreamWeaver, I'm thinking, and be useful for maintaining global page sections like nav menus.

I'm not really a programmer, but could probably tackle this with a code outline and indications of what syntax I need to learn.

Anyone done this? If Clip Programming is required, this is NTP specific. If regular expressions will suffice, then experience with any text editor supporting regex would probably apply. Thoughts?

 

Robert Charlton




msg:3319636
 5:52 am on Apr 24, 2007 (gmt 0)

Anyone?

Let me simplify the question....

Is there a way of using regex in a text search to identify two text strings, one at the beginning of a section and one at the end, and let me replace everything in between?

vincevincevince




msg:3319648
 6:09 am on Apr 24, 2007 (gmt 0)

More or less... with Perl type regular expressions you need to identify the text to change, and then change it.

An approximate syntax is:

/start text here .+? end text here/

You would need to escape special characters in the 'start text here' and 'end text here' sections.

. means anything, + means one or more of the previous, and the? modifies the + so that it goes for the shortest of possible solutions. All in all, it will look for the shortest string between 'start text here' and 'end text here'.

Altogether:
Search for: /start text here .+? end text here/
Replace with: something else....

Note that this removes 'start text here' and 'end text here'. If you want to keep them, either stick them in brackets in the search regex and access them in the replacement string with $1 and $2 (or similar) or just retype them in the replacement string.

phranque




msg:3319739
 8:48 am on Apr 24, 2007 (gmt 0)

sounds like a job for awk but my awk skills are too rusty to help beyond that suggestion.
being lazy, i would naturally write something in perl these days...

Robert Charlton




msg:3324642
 6:45 am on Apr 28, 2007 (gmt 0)

...with Perl type regular expressions...

vvv - I'm not a programmer, but I can follow syntax if I'm pointed to it. Question is whether what you're suggesting can just be entered into the search field, or whether I need to run Perl or some such within my text editor (I ask this sloppily, because I really don't know what's involved).

Way back when I used MS Word for DOS as a text editor, I was able to use its macro and scripting language (which were very easy to use) to do a lot of search and replace routines... even to find strings, move them, and change case.

But here I was just hoping for something very simple... basically something that I could enter into the search and replace fields, maybe with something like regex which I understand NoteTab Pro supports.

NoteTab Pro also has a Clip scripting language that I haven't used. The documentation assumes more of a background in programming than I have.

Robert Charlton




msg:3332696
 5:00 am on May 7, 2007 (gmt 0)

More or less... with Perl type regular expressions you need to identify the text to change, and then change it.

An approximate syntax is:

/start text here .+? end text here/

vvv - Finally have come to understand what you were talking about... ie, you're talking about the particular regular expressions syntax, not about using Perl itself.

When I said I'm not a programmer, I really meant it. ;)

Thanks.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved