On Apr 20, 2012, at 06:12, Javi Pérez wrote:
I have this text in a variable
...
and I want to get the line contain "Disk" (not always the first line)
______________________________________________________________________
Thomas gave you a nice vanilla Applescript solution. Here are some more options.
set myList to "SMB NORTHBRIDGE CHIP DIE: 51 C
SMC BATTERY: 35 C
SMART Disk Hitachi HTS545050B9SA02 (100826PBL40017J9VZTV): 32 C
SMC BATTERY POSITION 2: 35 C
"
# Grep
set foundLine to do shell script "egrep -i 'disk' <<< " & quoted form of myList
# Sed
set foundLine to do shell script "sed -n '/[dD]isk/p' <<< " & quoted form of myList
# Awk
set foundLine to do shell script "awk '/[dD]isk/' <<< " & quoted form of myList
# Perl
set foundLine to do shell script "perl -wlne 'if (m/(?ims)(^.+disk.+)/) {print \"$1\"}' <<< " & quoted form of myList
set foundLine to find text ".+disk.+" in myList with regexp and string result without case sensitive
tell application "ASObjC Runner"
set foundLine to look for "^.+disk.+" in myList options "im"
if foundLine is not {} then set foundLine to item 1 of foundLine
end tell
After search I just find ways to get an offset as much
I'm not following you here.