[TxMt] Re: How can I add a sequencial number to this Find/Replace?

René Schwaiger sanssecours at f-m.fm
Sat Feb 21 07:11:36 UTC 2015


Hi,

> On 20 Feb 2015, at 21:57 , jgalt <jgaltusa at gmail.com> wrote:
> 
> Sorry, my previous example file was not formatted properly and it got
> truncated. Here is a revised example file as XML: http://goo.gl/el0QMT

Could it be that the first and second uploads are the same file? They have the same file size, modification date and md5 hash:

MD5 (jgalt_replacement_example.zip) = c25e2dad9e95a3ce2d00c26fda8f14f4
MD5 (jgalt_replacement_example_v2.zip) = c25e2dad9e95a3ce2d00c26fda8f14f4


> On 20 Feb 2015, at 21:45 , jgalt <jgaltusa at gmail.com> wrote:
> 
> Thanks for taking the time to create the bundle for me René.
> 
> I have installed it but I am not 100% sure how to use it.
> 
> I have entered the shortcut key command “^⌥⌘R” and it appears to run but I
> do not understand how to target the parts that I want to replace.

The command reads the current selection — if there is none, then it reads the whole file — and replaces every occurrence of the regex with the result of the first capture (`match.group(1)`), followed by a sequential number (`index`), and the result of the second capture (`match.group(2)`).

Which part are targeted depends on your selection and the regex. Since there were two minor mistakes in the regex it should not have replaced anything for you. To fix the regex:

1. Open the bundle editor `^⌥⌘B`
2. Go to Subsitute→Menu Actions→Subsitute
3. Replace
   
    """(<PortalOBj portalFlags="16" numbOfRows="1" initialRow=")\d+(">)"""

with the correct regex (`PortalObj` instead of `PortalOBj`, `numOfRows` instead of `numbOfRows`):

    """(<PortalObj portalFlags="16" numOfRows="1" initialRow=")\d+(">)"""

4. Save the changes `⌘S`

The zip you sent contained a screenshot of a file, where you wanted to replace the number 1-15 with the numbers 16-30. If you want to do that you can just replace the regex with the following:

    """(<PortalObj portalFlags="16" numOfRows="1" initialRow=")(?:[1-9]|1[0-5])(">)"""

It should not do anything on the file you sent though, since that contained `initialRow` numbers ranging from 31-45.

> Here is a screen capture of my find and replace settings:
> http://goo.gl/YBqYy9
> 
> Here is a zipped file of the file that I am trying to edit:
> http://goo.gl/XOkDRh
> 
> I don't know if it matters...but the content that I am trying to edit is
> from a FileMaker clipboard. I believe that it is in XML format. The items
> that I am trying to edit are references to layout elements. (More
> specifically, references to FileMaker Portals.)
> 
> Thanks again for your help!

Kind regards,
  René


More information about the textmate mailing list