FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
Sasha_FTNT
Staff
Staff
Article Id 189895

Description

 

This article describes how to insert the question mark into regular expressions.

By default, the symbol '?' is used to show the help menu.
But sometimes, it is required inside the regular expressions, as the question mark makes the preceding token in the regular expression optional.

 

Scope

 

FortiGate.

Solution


As the symbol of a question mark is reserved to help menu, it will be impossible to copy-paste or type this symbol into some expressions.

Here is the simple snippet from DLP dictionary:

 

config dlp dictionary
    edit "default"
        config entries
            edit 1
                set type regex
                set pattern "(?s:(\\d{10}.*))"
            next
        end
    next
end

 

To be able to insert the question mark, the following options are available:

  1. Press 'Ctrl V ?'. This method only works in Putty and won't work for copy and paste.
  2. Press 'Ctrl Shift - ?'. This method works in Putty and FortiGate GUI CLI Console. It also allows copy and paste URLs or lines containing a ?. For example: 'Ctrl Shift -' and then 'Ctrl V' to paste.
  3. Use batch mode by following this article: Technical Tip: How to paste question marks (?) in the CLI using batch mode.

 

Note: In batch mode, it is not possible to run the 'show' command to check the existing configuration, or press 'Tab' to auto-complete sub-commands, or press '?' to list all available commands. It is important to know the exact commands to run. This method works well for bulk configuration (copy and paste). 

 

Related article: 

Technical Tip: How to enter '?' (Question mark character) in the FortiGate CLI