Adding text from string



  • Hello there, I would like to know if is possible from ReportItem line select only the pluginName value without " " and then

    <ReportItem port="111" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="11111" pluginName="RPC Services Enumeration" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    

    add this whole line value after the plugin_modification_date: <plugin_name>value selected from above and inserted here</plugin_name>

    <ReportItem port="111" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="11111" pluginName="RPC Services Enumeration" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    <plugin_name>RPC Services Enumeration</plugin_name>
    

    This became a nightmare coz there´s no <plugin_name> item and then the code breaks.

    Really appreciate for the attention.



  • Hello, @francesco-ferrari and All,

    No problem with regexes !. So let’s imagine the following INPUT text :

    <ReportItem port="111" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="11111" pluginName="RPC Services Enumeration" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    .....
    .....
    .....
    </ReportItem>
    
    <ReportItem port="222" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="22222" pluginName="A funny Name" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    .....
    .....
    .....
    </ReportItem>
    
    <ReportItem port="333" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="33333" pluginName="XXXXX yyyyy ZZZZZ" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    .....
    .....
    .....
    </ReportItem>
    

    Then :

    • Open the Replace dialog ( Ctrl + H )

      • SEARCH (?-is)<ReportItem\x20.+?pluginName="(.+?)"(?s).+?</plugin_modification_date>\R

      • REPLACE $0<plugin_name>\1</plugin_name>\r\n

      • Tick the Wrap around option, ONLY

      • Select the Regular expression search mode

      • Click on the Replace All button

    You should get the expected OUTPUT text, below :

    <ReportItem port="111" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="11111" pluginName="RPC Services Enumeration" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    <plugin_name>RPC Services Enumeration</plugin_name>
    .....
    .....
    .....
    </ReportItem>
    
    <ReportItem port="222" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="22222" pluginName="A funny Name" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    <plugin_name>A funny Name</plugin_name>
    .....
    .....
    .....
    </ReportItem>
    
    <ReportItem port="333" svc_name="rpc-portmapper" protocol="tcp" severity="0" pluginID="33333" pluginName="XXXXX yyyyy ZZZZZ" pluginFamily="Service detection">
    <description>test</description>
    <plugin_modification_date>2011/05/24</plugin_modification_date>
    <plugin_name>XXXXX yyyyy ZZZZZ</plugin_name>
    .....
    .....
    .....
    </ReportItem>
    

    Note that I suppose that the string </plugin_modification_date> always ends the current line

    Best Regards,

    guy038



  • @guy038 said in Adding text from string:

    $0<plugin_name>\1</plugin_name>\r\n

    WOW!!! You are just the best!!! :))))

    It worked first atemption!!!

    Thank you very much for your help!!!

    Best regards

    Franthesco


Log in to reply