Search & replace between x and y

Post here if your topic is about CSS HTML Validator but doesn't fit in another forum.
Post Reply
markwolk
Rank III - Intermediate
Rank III - Intermediate
Posts: 50
Joined: Mon Jul 04, 2005 3:11 am
Contact:

Search & replace between x and y

Post by markwolk » Mon Oct 01, 2012 5:10 am

Are you aware of a multiple file search & replace program for Windows 7, that would allow to replace portions between specific portions of text, e.g. between
<!-- here -->
and
<!-- there -->
?

Freeware ReplaceText did that job very well, but unfortunately does not work on Windows 7.

I purchased "Multiple File Search and Replace 2.2", but unfortunately it is not as good.

Any other suggestions... short of learning Regular Expressions?

... Or is it just a simple Regex I can use with my CSE HTML Validator Standard 11.0230?

Usually I try to stay away from Regex's because I find them very obscure :?
Mark Wolk

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3316
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Search & replace between x and y

Post by Albert Wiersch » Mon Oct 01, 2012 7:45 am

Hi Mark,

Yes, it is unfortunate Replace Text (BK ReplaceEm) does not work properly on Windows 7/8.

I currently use this old search & replace program which does work:
http://www.fauland.com/af9.htm

Unfortunately it's not as powerful, but it's great for simple text search & replaces without regular expressions.

RegEx's are great, but they can certainly be confusing. I'm sure there are good 'starter' tutorials on the web.

As for doing this in CSE HTML Validator, I believe it can be done but it would only work on the current document or on all the documents you have open. Is this what you want or did you want to search & replace a lot of files without having them all open in the editor? If you want me to give more specifics on doing this with CSE HTML Validator, then let me know.

Another option may be TopStyle as I believe it has more powerful search & replace operations. You may want to try the TopStyle 5 BETA.
Image
Albert Wiersch

markwolk
Rank III - Intermediate
Rank III - Intermediate
Posts: 50
Joined: Mon Jul 04, 2005 3:11 am
Contact:

Re: Search & replace between x and y

Post by markwolk » Mon Oct 01, 2012 11:27 am

Thanks, Albert.

I think that af9 does not allow range search (replace text between text identifiers)... does it?

If achieving this is possible within CSE HTML Validator, I'd appreciate some guidance (regex?). Opening all documents does not make it impossible for me, because most of my sites are under 100 pages. And I have a lready managed to replace exact match text across an entire website using CSE HTML Validator; the only thing I could not do is replace within a text range.
Mark Wolk

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3316
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Search & replace between x and y

Post by Albert Wiersch » Mon Oct 01, 2012 2:05 pm

markwolk wrote:I think that af9 does not allow range search (replace text between text identifiers)... does it?
No, I don't think it does. It would be great if it supported regular expressions but I don't think it does.
markwolk wrote:If achieving this is possible within CSE HTML Validator, I'd appreciate some guidance (regex?). Opening all documents does not make it impossible for me, because most of my sites are under 100 pages. And I have a lready managed to replace exact match text across an entire website using CSE HTML Validator; the only thing I could not do is replace within a text range.
Try searching for something like (with regular expressions on):

Code: Select all

<!-- here -->.*?<!-- there -->
If you want to match line breaks, then try adding (?s):

Code: Select all

(?s)<!-- here -->.*?<!-- there -->
The "(?s)" part is a modifier that makes the '.' character also match line breaks by treating the entire document as a single line.

And then replace with what you want.

I hope this helps. If you need more help, then just let me know and I'll try to help further.
Image
Albert Wiersch

markwolk
Rank III - Intermediate
Rank III - Intermediate
Posts: 50
Joined: Mon Jul 04, 2005 3:11 am
Contact:

Re: Search & replace between x and y

Post by markwolk » Mon Oct 01, 2012 3:43 pm

That does not work :(
Mark Wolk

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3316
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Search & replace between x and y

Post by Albert Wiersch » Mon Oct 01, 2012 4:01 pm

markwolk wrote:That does not work :(
It worked in my tests. I'll need more specifics to troubleshoot though, like exactly what you are trying to search/replace and a sample document.
Image
Albert Wiersch

markwolk
Rank III - Intermediate
Rank III - Intermediate
Posts: 50
Joined: Mon Jul 04, 2005 3:11 am
Contact:

Re: Search & replace between x and y

Post by markwolk » Mon Oct 01, 2012 4:45 pm

Human error. I had forgotten to check Regular Expressions.

It seems to work now :D Thanks.
Mark Wolk

Post Reply