Search code examples
regexuimarutapega

Get last 3 characters of matched pattern RUTA


I am trying to get last 3 characters of a pattern. But I am stuck on how to do it.

Please share your thoughts on this.

PACKAGE uima.ruta.example;

Document{->RETAINTYPE(SPACE)};

DECLARE VarA;

((W|NUM)* (W|NUM)*){REGEXP(".{12}")-> MARK(VarA),MARK(EntityType,1), UNMARK(VarA)};

I/P - AB1234567CAB

O/P - CAB


Solution

  • I tried below code and its working now!

    PACKAGE uima.ruta.example;
    
    Document{->RETAINTYPE(SPACE)};
    
    "(?i)\\b(?=.*\\d)[1]{0,1}[A-Z0-9]{2}[\\s |-]{0,2}[A-Z0-9]{7}[\\s |-]{0,2}([A-Z]{3})\\b" ->1 = EntityType;