Lua’s string
library supports a lot of handy string operations. Strings will obviously be used frequently when writing NSE scripts because they represent a byte sequences. Let’s review the most common functions for string handling.
Character classes are special operators used in patterns. We will need them when matching or subtracting substrings, so keep them in mind while we review patterns and string operations. Character classes are as follows:
. | All characters |
%a | Letters |
%c | Control characters |
%d | Digits |
%l | Lower case letters |
%p | Punctuation characters |
%s | Space characters |
%u | Upper case letters |
%w | Alphanumeric characters |
%x | Hexadecimal digits |
%z | Null (0x90) |
The following characters have special functions within patterns:
( ) | Define captures |
. | Any character |
% | Escape character for magic characters and nonalphanumeric characters |
+ | Repetition operator |
- | Repetition operator |
* | Repetition operator |
? | Repetition operator |
[ | Define sets |
^ | Represent the complement of the set |
$ | Represent the end... |