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 aroundoption, ONLY -
Select the
Regular expressionsearch mode -
Click on the
Replace Allbutton
-
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 lineBest 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
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