Recently, while working through an Office 365 Hybrid migration for a customer, we needed to bring the Exchange Online Protection IP address ranges into their firewall for policy changes. Microsoft publishes this list here: https://technet.microsoft.com/en-us/library/dn163583%28v=exchg.150%29.aspx. Unfortunately, I needed them in the following format:
config firewall address
set subnet 184.108.40.206/22
Thankfully, this was made much easier with using Word find/replace with the following syntax:
Replace: edit ExchangeOnline-\1.\2.\3.\4^lset subnet \1.\2.\3.\4/\5 ^lnext^l
set subnet 220.127.116.11/22
Simply copy and paste into SSH, upload script, etc. and you’re sorted!
Do not upload in script commands to fortigate more than 200 lines!
if there is more do it in 2 scripts