powerofos Posted June 30, 2021 Share Posted June 30, 2021 (edited) #include <MsgBoxConstants.au3> #include <StringConstants.au3> Local $aArray = 0, $iOffset = 1 Local $string = "<a>1</a><b>2</b><c>3</c><d>4</d><e>5</e>|<a>1-1</a><b>2-1</b><c>3-1</c><d>4-1</d><e>5-1</e>|<a>1-2</a><b>2-2</b><c>3-2</c><d>4-2</d><e>5-2</e>|" While 1 $aArray = StringRegExp($string, '(?i)<a>(.*?)</a><b>(.*?)</b><c>(.*?)</c><d>(.*?)</d><e>5-1</e>', $STR_REGEXPARRAYMATCH, $iOffset) If @error Then ExitLoop $iOffset = @extended For $i = 0 To UBound($aArray) - 1 MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 1 - ", $aArray[0]) Next WEnd Hello guys, how i get data from <a>?</a> where condition <e>5-1</e> in one time runing? (not in while loop?) Thanks a lot! Edited June 30, 2021 by powerofos Link to comment Share on other sites More sharing options...
Luke94 Posted June 30, 2021 Share Posted June 30, 2021 (edited) Removed. Realized this isn't what you wanted. Edited June 30, 2021 by Luke94 Link to comment Share on other sites More sharing options...
Luke94 Posted June 30, 2021 Share Posted June 30, 2021 What about this? #include <Array.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> ;Local $aArray = 0, $iOffset = 1 Local $string = "<a>1</a><b>2</b><c>3</c><d>4</d><e>5</e>|<a>1-1</a><b>2-1</b><c>3-1</c><d>4-1</d><e>5-1</e>|<a>1-2</a><b>2-2</b><c>3-2</c><d>4-2</d><e>5-2</e>|" Global $g_aStringSplit = StringSplit($string, Chr(124), $STR_NOCOUNT) For $i = 0 To (UBound($g_aStringSplit) - 1) Step 1 If StringRegExp($g_aStringSplit[$i], '(?i)<a>(.*?)</a><b>(.*?)</b><c>(.*?)</c><d>(.*?)</d><e>5-1</e>', $STR_REGEXPMATCH) = 1 Then Global $g_aArray = StringRegExp($g_aStringSplit[$i], '(?i)<a>(.*?)</a><b>(.*?)</b><c>(.*?)</c><d>(.*?)</d><e>(.*?)</e>', $STR_REGEXPARRAYMATCH) _ArrayDisplay($g_aArray) EndIf Next ;~ While 1 ;~ $aArray = StringRegExp($string, '(?i)<a>(.*?)</a><b>(.*?)</b><c>(.*?)</c><d>(.*?)</d><e>5-1</e>', $STR_REGEXPARRAYMATCH, $iOffset) ;~ If @error Then ExitLoop ;~ $iOffset = @extended ;~ For $i = 0 To UBound($aArray) - 1 ;~ MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 1 - ", $aArray[0]) ;~ Next ;~ WEnd I'm not the best with RegEX though. I'm sure you'll get some better solutions. powerofos 1 Link to comment Share on other sites More sharing options...
Nine Posted June 30, 2021 Share Posted June 30, 2021 How about this one : #include <Array.au3> Local $string = "<a>1</a><b>2</b><c>3</c><d>4</d><e>5</e>|<a>1-1</a><b>2-1</b><c>3-1</c><d>4-1</d><e>5-1</e>|<a>1-2</a><b>2-2</b><c>3-2</c><d>4-2</d><e>5-2</e>|" Local $aArray = StringRegExp($string,"(?i)<a>(.{1,3})</a><b>.{1,3}</b><c>.{1,3}</c><d>.{1,3}</d><e>5-1</e>", 1) _ArrayDisplay($aArray) Luke94 and powerofos 2 “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
powerofos Posted June 30, 2021 Author Share Posted June 30, 2021 @Luke94 Thanks, idea from Nine is good! @Nine,thanks,it's perfect for me! Link to comment Share on other sites More sharing options...
mikell Posted July 1, 2021 Share Posted July 1, 2021 (edited) For a bit of versatility (and for fun) #include <Array.au3> Local $string = "<a>1</a><b>2</b><c>3</c><d>4</d><e>5</e>|<a>1-1</a><b>2-1</b><c>3-1</c><d>4-1</d><e>5-1</e>|<a>1-2</a><b>2-2</b><c>3-2</c><d>4-2</d><e>5-2</e>|" $var = "b" $if = "5-2" Local $aArray = StringRegExp($string, '<' & $var & '>(.{1,3})</' & $var & '>[^\|]*<e>' & $if & '</e>', 1) _ArrayDisplay($aArray) Edited July 1, 2021 by mikell powerofos 1 Link to comment Share on other sites More sharing options...
Factfinder Posted July 2, 2021 Share Posted July 2, 2021 Also for fun but with StringRegExpReplace: #include <Array.au3> Local $string = "<a>1</a><b>2</b><c>3</c><d>4</d><e>5</e>|<a>1-1</a><b>2-1</b><c>3-1</c><d>4-1</d><e>5-1</e>|<a>1-2</a><b>2-2</b><c>3-2</c><d>4-2</d><e>5-2</e>|" $ret = StringRegExpReplace($string, ".*<a>([^<]+)</a>[^\|]+<e>5-1</e>.*", "$1") MsgBox(0, '', $ret) powerofos 1 Link to comment Share on other sites More sharing options...
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