Luigi Posted November 5, 2019 Posted November 5, 2019 (edited) Greetings, Someone can help-me with this regex? start1 a,b,c aaa,bbb,ccc dd,ee,ff a1,a2,a3 b1,b2,b3 c1,c2,c3 end1 start2 aa,bb,cc dd,ee,ff a1,a2,a3 b1,b2,b3 c1,c2,c3 end2 Obs: have multiples start? - end? each block have 3 words, each word have numbers, latters with any lenght Need catch an array $arr1 = ["a", "b", "c", "aaa", "bbb", "ccc", "dd", "ee", "ff", "a1", "a2", "a3", "b1", "b2", "b3", "c1", "c2", "c3"] $arr2 = ["aa", "bb", "cc", "dd", "ee", "ff", "a1", "a2", "a3", "b1", "b2", "b3", "c1", "c2", "c3"] Best regards. This is not clever... But resolve with 2 regex... Is possible solve this with one regex? Local $regex1 = "(?s)start1(.*?)end1" Local $regex2 = "\w+" Local $raw_antes = " start1 aa,bb,cc dd,ee,ff g,h,i @ end1 " Local $arr = StringRegExp($raw_antes, $regex1, 3) If IsArray($arr) Then $arr = $arr[0] ConsoleWrite("@Ok1" & @LF) $arr = StringRegExp($arr, $regex2, 3) If IsArray($arr) Then For $ii = 0 To UBound($arr, 1) - 1 Step 3 ConsoleWrite($arr[$ii] & ", " & $arr[$ii + 1] & ", " & $arr[$ii + 2] & @LF) Next Else ConsoleWrite("@Erro2" & @LF) EndIf Else ConsoleWrite("@Erro1" & @LF) EndIf Edited November 5, 2019 by Luigi Visit my repository
Danyfirex Posted November 5, 2019 Posted November 5, 2019 Hello. maybe this: Local $aReg=StringRegExp($String,"([0-9a-f]{2})",3) saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Luigi Posted November 5, 2019 Author Posted November 5, 2019 7 minutes ago, Danyfirex said: Hello. maybe this: Local $aReg=StringRegExp($String,"([0-9a-f]{2})",3) saludos So sorry @Danyfirex... I forgot write something... It was completed... Visit my repository
Danyfirex Posted November 5, 2019 Posted November 5, 2019 try this: Local $aReg=StringRegExp($String,"\b(?!(end|start))[0-9a-z]{1,}\b",3) Saludos Luigi 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Luigi Posted November 5, 2019 Author Posted November 5, 2019 3 minutes ago, Danyfirex said: try this: Local $aReg=StringRegExp($String,"\b(?!(end|start))[0-9a-z]{1,}\b",3) I update for: Local $aReg=StringRegExp($String,"\b(?!(end|start))\w+\b",3) Work fine. Thank you @Danyfirex Danyfirex 1 Visit my repository
mikell Posted November 5, 2019 Posted November 5, 2019 another flavour StringRegExp($txt,"(?:start|end)(*SKIP)(*F)|\b(\w+)\b", 3) Musashi and Danyfirex 2
Nine Posted November 5, 2019 Posted November 5, 2019 Or a non regexp ? #include <Array.au3> $sTxt1 = "start1 a,b,c aaa,bbb,ccc dd,ee,ff a1,a2,a3 b1,b2,b3 c1,c2,c3 end1" $sTxt2 = "start2 aa,bb,cc dd,ee,ff a1,a2,a3 b1,b2,b3 c1,c2,c3 end2" $a1 = StringSplitEX ($sTxt1) _ArrayDisplay ($a1) $a2 = StringSplitEX ($sTxt2) _ArrayDisplay ($a2) Func StringSplitEX ($sString) Local $aArray = StringSplit ($sString, ", ", $STR_CHRSPLIT+$STR_NOCOUNT) _ArrayDelete ($aArray, "0;" & UBound($aArray)-1) Return $aArray EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
mikell Posted November 5, 2019 Posted November 5, 2019 The challenge was apparently to make a one-liner Anyway regex is very versatile #Include <Array.au3> $txt = "start1 a,b,c aaa,bbb,ccc dd,ee,ff a1,gosh... ,a2,a3 b1,b2,b3 heyhey c1,c2,c3 end1" $res = StringRegExp($txt,"(?:start|end|gosh|hey)(*SKIP)(*F)|\b(\w+)\b", 3) _ArrayDisplay($res)
Nine Posted November 5, 2019 Posted November 5, 2019 1 hour ago, mikell said: to make a one-liner Ya so sorry. Mine has 2 lines. That's 100% more. Terrible. So sorry. FrancescoDiMuro 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now