Help: Search/Replace: How to search for start and end tag, t

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Anders Holt

Help: Search/Replace: How to search for start and end tag, t

Post by Anders Holt »

I can not seem to figure out how to search and replace a textblock, which is tagged in start and end, to replace the whole block of text.

I need this, to do a S/R to easier change an element with a lot of code in it, which may not be completely identical in all the (html) documents.

Is there any solution here?

Yours,
Anders Holt
Anders Holt

Re: Help: Search/Replace: How to search for start and end ta

Post by Anders Holt »

I think this is the same question as formulated in this question, which also has not got any answers:
http://www.textpad.com/forum/read.php?f=1&i=3146&t=3146

Please help!

Yours,
Anders Holt
Ed

Re: Help: Search/Replace: How to search for start and end ta

Post by Ed »

I don't know if this will be any help - (I'm not that familiar with HTML which I guess this concerns) but..
if what you have is <start some other text end>
then search for
<start.*end>
with regular expression checked will find it, provided there's no newline character in between. But somehow I don't think this will be what you want.
If there are newlines scattered around then life is more complicated but generally changing them into something else doing the replacement and then changing them back is a plausible solution.
Could you supply a before and after example? I'm sure someone will help if they understood the problem a bit better.
MO

Re: Help: Search/Replace: How to search for start and end ta

Post by MO »

The problem is the question is not exactly clear as to which of a number of things he wants to do. He should give an example. Some possible solutions:

Find what: ^<p>\([^<]+\)</p>$
Replace with: <p class="example"><span class="exanoke">\1</span></p>


Find anywhere in line: <font face="FontName">\([^<]+\)</font>
Replace with: <span class="FontName">\1</span>

Find: <\([^<]+\)>
Replace with: [\1]


elect whole line and add something to the beginning and end.

Find: ^\(.+\)$
Replace with: xxx\1xxx
Anders Holt

Re: Help: Search/Replace: How to search for start and end ta

Post by Anders Holt »

To expand my problem a bit:

What I would like to do, is to put a tag in front of a textblock, and
at the end, and then use this is the "search-argument", to be able to
search and replace all code inbetween the tags.

In other words, I would like tho use the tags as a replacments for
the old dos: *.*

This because I do not always know exactely what kind of code that is
between the tags. And in this way, I can expand or subbtract a piece
of code and do a S/R on as many documents I like at one time, without
taking into consideration if the code is different in any way (e.g. a
space to much or whatever).

Here is an example (the code in the middle is just some html-code):

where start tag is : <!--tag_for_SR-->
and end tag is: <!--tag_for_SR_end-->


<!--tag_for_SR-->

<!-- Signatur stripe nederst på siden-->
<!-- Mellomroms tabell -->
<table>
<tr>
<td class="mellomrom"></td>
</tr>
</table>
<!-- Slutt på Mellomroms tabell -->
<Table border="0" cellpadding="0" width="771" cellspacing="0">
<tr>
<td class="m_farget" width="5"></td>
<td class="m_farget" width="120" ></td>
<td class="m_farget" width="11" ></td>
<td class="m_farget" width="512" >
<span class="tekst_signatur">
<a class="meny" href="om_disse_sidene.html">Om disse
sidene</a>
</span>
</td>
<td class="m_farget" width="120" ></td>
<td class="m_farget" width="5" > </td>
</tr>
</table>
<!-- Slutt p&aring Signatur stripe nederst på siden-->

<!--tag_for_SR_end-->

Yours,
Anders Holt
Ed

Re: Help: Search/Replace: How to search for start and end ta

Post by Ed »

with Reg expression on
Search for
\n
replace with
¬
Search for
<!--tag_for_SR-->.*<!--tag_for_SR_end-->
Replace with
new text
(with newlines represented as ¬)
Search for
¬
replace with
\n
Anders Holt

Re: Help: Search/Replace: How to search for start and end ta

Post by Anders Holt »

Thank you so much - I will try this! It still involves several operations, but this will still be simpler, if one has to do it on about 25 or more htmlpages.
Yours,
Anders
Post Reply