Help Parsing Text

Issue #517 resolved
TechTimeS created an issue

Hi there,

I have a custom field created by another Add-on, that I would like to parse content of the field into a text box.

The field itself is a nice colourful lozenge.

When I use the post function for parsing, I get the following result:

  • Exposure {id=3, name='High', description='', severity=3, bgColor=java.awt.Color[r=255,g=0,b=0], fgColor=java.awt.Color[r=255,g=255,b=255]}*

While I know this is what makes up the custom field and how it displays, is there anyway, I can just extract the name variable using the post function?

Thanks, Nikki

Comments (3)

  1. Fidel Castro Armario repo owner

    Hi Nikki,

    You have 2 possible solutions:

    #Using a Post-Function for extracting the value:# Use "Parse field for extracting data" with the following configuration:

    Captura de pantalla 2017-02-20 a las 8.34.46.png Captura de pantalla 2017-02-20 a las 8.35.13.png Where:

    • Leading delimiter is:
    name='
    
    • Value pattern is:
    [^']*
    
    • Trailing delimiter is:
    '
    

    #Using a Calculated Text Field:#

    You can create a Calculated Text Field called "Exposure's Name" with the following configuration:

    Captura de pantalla 2017-02-20 a las 8.55.17.png

    Text to be parsed is:

    replaceFirst(replaceFirst(%{nnnnn}, "^.*name='", ""), "(?s)'.*$", "")
    

    replacing nnnnn with field code for Exposure.

    This field will always be updated, showing the correct value in synchronization with field Exposure. I think this is maybe a better solution, but take into account that Calculated Fields are computed each time they are viewed, and in same cases it may cause a performance penalty in the system.

  2. TechTimeS Account Deactivated reporter

    Hi Fidel,

    Thank you so much. I went with the first option and it works perfectly.

    Fantastic support!

    Nikki

  3. Log in to comment