Jump to content

Extract String


Queener
 Share

Recommended Posts

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

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

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)

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Another one :

$string = "ID:9999 | James Crawler | Data Entry | Age: 19 | MTWTF|RM101"
$extract = StringRegExpReplace($string, "^[^|]*\|\h*|\h*\|\N*", "")
ConsoleWrite($extract)

 

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...