Community
    • Login

    Adding text from string

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 196 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Francesco FerrariF
      Francesco Ferrari
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by guy038

        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

        Francesco FerrariF 1 Reply Last reply Reply Quote 2
        • Francesco FerrariF
          Francesco Ferrari @guy038
          last edited by

          @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

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors