Queener Posted October 12, 2016 Share Posted October 12, 2016 I'm not sure about how to do this. Can someone help? I have long list that piped and each of the line, I only want the string within the second and third piper. For example: ID:9999 | James Crawler | Data Entry | Age: 19 | MTWTF|RM101 I only want to extract the James Crawler and leave out the rest. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
AutoBert Posted October 12, 2016 Share Posted October 12, 2016 One of possible solutions: #include <MsgBoxConstants.au3> #include <StringConstants.au3> $sData='ID:9999 | James Crawler | Data Entry | Age: 19 | MTWTF|RM101' $aSplit=StringSplit($sData,'|', $STR_NOCOUNT) MsgBox($MB_ICONINFORMATION,'Wanted:',$aSplit[1]) Queener 1 Link to comment Share on other sites More sharing options...
Queener Posted October 12, 2016 Author Share Posted October 12, 2016 Thank you so much, I did find another way, but I like yours. ;Variables to locate the right columns $SearchString = GUICtrlRead(GUICtrlRead($List_Status)) $SearchString = _StringBetween($SearchString, "|", "|") $SearchString = $SearchString[0] Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Gianni Posted October 12, 2016 Share Posted October 12, 2016 Another possible solution (... a tribute to Rube Goldberg ) Local $sData = 'ID:9999 | James Crawler | Data Entry | Age: 19 | Rube Goldberg | MTWTF|RM101' Local $iItem = 5 ; wanted item Local $SearchString = StringMid($sData, StringInStr($sData, '|', 0, $iItem - 1) + 1, StringInStr($sData, '|', 0, $iItem) - (StringInStr($sData, '|', 0, $iItem - 1) + 1)) MsgBox(0, "Debug", $SearchString) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
ThioFoX Posted October 12, 2016 Share Posted October 12, 2016 Alternatives: $sText = "ID:9999 | James Crawler | Data Entry | Age: 19 | MTWTF|RM101 " $aExtract = StringRegExp($sText, "(.*?)\|", 3) MsgBox(4096, "", $aExtract[1]) $sExtract = StringRegExpReplace($sText, "^.*?\|(.*?)\|.*$", "$1") MsgBox(4096, "", $sExtract) Link to comment Share on other sites More sharing options...
jguinch Posted October 12, 2016 Share Posted October 12, 2016 Another one : $string = "ID:9999 | James Crawler | Data Entry | Age: 19 | MTWTF|RM101" $extract = StringRegExpReplace($string, "^[^|]*\|\h*|\h*\|\N*", "") ConsoleWrite($extract) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
mikell Posted October 12, 2016 Share Posted October 12, 2016 $string = "ID:9999 | James Crawler | Data Entry | Age: 19 | MTWTF|RM101" $extract = StringRegExpReplace($string, "^[^|]*\|([^|]*).*", "$1") ConsoleWrite($extract) Link to comment Share on other sites More sharing options...
Jfish Posted October 12, 2016 Share Posted October 12, 2016 The other solutions are better but just tossing the trimming concept out there as well ... $string = "ID:9999 | James Crawler | Data Entry | Age: 19 | MTWTF|RM101" $extractLeft=stringtrimleft($string,StringInStr($string,"|")) $extractRight=StringTrimRight($extractLeft,stringlen($extractLeft)-StringInStr($extractLeft,"|")+1) ConsoleWrite($extractRight&@crlf) Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt 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