Community
    • Login

    Adding text from string

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 424 Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors