Search and replace instance

Hi everybody,

I have list of instance B1,B2,....Bn and A1,A2,....An.
How can i replace B1 = A1, B2 = A2 ... Bn = An by using "search and replace" query

thanks.

dai

Comments

  • You mean the names of the new cells are constructed by replacing the "A" prefix by "B"?

    Here is such a custom query:

    with instances of cells * where cell_name ~ "A(*)" do inst.cell_index = <<"B"+$1>>
    

    This may need some explanation:

    "instances of cells *" is a bit misleading (owned to the pseudo-natural language of the query): it actually means "instances contained in all cells". So "with instances of cells *" is a loop over all instances of all cells.

    "cell_name" is referring to the "cell_name" attribute of these instances, "~" is the match operator. It accepts a "glob pattern" (think shell) and "A(*)" will match all A-prefixed names. The remaining part is captured by the bracket. It will become available as "$1" in the subsequent expressions.

    <<"B"+$1>> is a cell reference by name (name string expression inside double angle brackets) and resolves into a cell index which can be assigned to the instance's cell_index attribute.

    Hope that's not too confusing :)

    Matthias

  • Thanks Matthias,

    This is exactly what I want.
    Your explanation is very clearly Matthias. :heart: :heart: :heart: :heart: :heart:

    :smile: :smile:
    thanks again.
    daipv

Sign In or Register to comment.