Error in Rename By Replacing with RegEx

User: "batstache611"
New Altair Community Member
Updated by Jocelyn

Hello,

I'm getting the following error while trying to use Rename by Replacing with the help of RegEx -

 

"An attribute was already present in the example set which is not allowed because attribute names must be unique."

 

 

What does this mean? My attribute names ARE unique. The attribute names come from a %{file_name} macro from loop files and contain *.xlsx in their names since the files happen to be spreadsheet dictionary files each with it's own unique name. Its that .xlsx that I'm trying to get rid of by using regular expressions because otherwise in my next operator which is Generate Attributes, my IF() statement fails because of the ".x" in the xlsx.

 

Thank you for your help!

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "IngoRM"
    New Altair Community Member
    Accepted Answer

    Ah, here we have the problem :smileyhappy:

     

    There are actually two mistakes in your regular expression:

     

    1. First, you need to quote the dot before the "xlsx".  Otherwise the regular expression parser reads it just as an arbitrary symbol (just like your first dot).  You can quote it by putting a backslash in front of it, i.e. use the following:
      .*\.xlsx
    2. This expression now will match file names ending with ".xlsx" and some arbitrary text before.  So that's basically all files and always the complete name, including the extension.  And then you replace the complete name with... nothing.  Which brings me to the second error.  You should use a so-called capture group in your expression and replace the match with the content of this group.  Use the following for the replace parameter:
      (.*)\.xslx
      and the following for the replace-by parameter:
      $1
      This will now replace the complete match (the first string) by only the content of the first capture group (indicated by $1, the second group would be $2 etc.).  You specify your capture groups with round parantheses.

    This should do the trick.  Learn more about capture groups here:

    http://www.javamex.com/tutorials/regular_expressions/capturing_groups.shtml

    http://docs.oracle.com/javase/tutorial/essential/regex/groups.html

     

    Hope this helps,

    Ingo