Hi

You might like to try this:

Find: (<col id="1">.+</)col

Replace: \01company

 From this Find/Replace expression you can probably guess what is  
going on.

. matches any character except return and + is a quantifier meaning  
one or more times.

It will do this up to </col because that is specified in the find  
expression and for that to match then .+ must finish before it.

The brackets in the Find expression capture this part to be included  
in the replace by \01.

Then as you see in the replace "col" does not appear, instead  
"company" does.

It might be that you wish to do this change to all the tags <col  
id="1"> through to <col id="10">

In which case we can change the Find expression to:

Find: (<col id="[0-9]+">.+</)col

with the replace expression unchanged.

[0-9] is a character class including the number 0 to 9. The + after it  
means one or more times so the id number can be as big as you like :)

Patrick

http://www.patrickjames.co.uk

On 19 Dec 2008, at 16:31, Chris wrote:

>
> Hi All
>
> I am trying to use grep for a find and replace on an xml document.
> What I am trying to do is select  id="1"
> then select the closing element "/col" to change to "/company".
>
>
>       <row id="2">
>               <col id="1">Sonitrol Corp.</col>
>               <col id="2">Joseph Tranfaglia</col>
>               <col id="3">1 Merrill St.</col>
>               <col id="4">Woburn</col>
>               <col id="5">MA</col>
>               <col id="6">01801</col>
>               <col id="7">www.sonitrol.com</col>
>               <col id="8">508-649-2019</col>
>               <col id="9">[email protected]</col>
>               <col id="10">Electronice Security, Monitoring, Fire 
> Inspections</
> col>
>               <col id="11">New England</col>
>       </row>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a specific feature request or would like to report a suspected (or 
confirmed) problem with the software, please email to "[email protected]" 
rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---

Reply via email to