Good morning
I'm playing with SRE and trying to obtain some information from a test file.
I was testing the pattern on regex101, but when I bring it to AutoIt, it doesn't return the same result as on regex101.
I am surely (?:missing some important notes about PCRE engine|the pattern is not correct at all).
Script:
#include <Array.au3>
#include <StringConstants.au3>
Test()
Func Test()
Local $strFileName = @ScriptDir & "\TestFile.txt", _
$strFileContent, _
$arrResult
$strFileContent = FileRead($strFileName)
If @error Then Return ConsoleWrite("FileRead ERR: " & @error & @CRLF)
$arrResult = StringRegExp($strFileContent, '(?sx)User:\h([^\n]+)\n' & _
'Login\-name:\h([^\n]+)\n' & _
'(?:CaseSensitive:\h([^\n]+)\n)?' & _
'NTSecurity:\h([^\n]+)\n' & _
'(?:NO\n)?' & _
'(?:Domain:\h([^\n]+)\n)?' & _
'Timeout:\h([^\n]+)\n' & _
'.*?' & _
'Member:\h([^\n]+)\n', $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult) Then _ArrayDisplay($arrResult)
EndFunc
Test file:
User: AMMINISTRATORE
Login-name: ADM
CaseSensitive: YES
NTSecurity: NO
NO
Timeout: 00:05:00
Member: AMMINISTRATORI
User: Test_User
Login-name: Test_User
NTSecurity: YES
Domain: DNEU
Timeout: 00:00:00
Member: OPERATORS
Member: OPERATORS
Any help (even from cats) it's highly appreciated.
Cheers