• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Find text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find text


  • Subject: Re: Find text
  • From: KOENIG Yvan <email@hidden>
  • Date: Fri, 20 Apr 2012 20:01:46 +0200


Le 20 avr. 2012 à 16:58, Javi Pérez a écrit :

This was a PRO answer, thanks


Enviado con
El viernes 20 de abril de 2012 a las 16:45, Christopher Stone escribió:

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 ofmyList

# Sed
set foundLine to do shell script "sed -n '/[dD]isk/p' <<< " & quoted form ofmyList

# Awk
set foundLine to do shell script "awk '/[dD]isk/' <<< " & quoted form ofmyList

# Perl
set foundLine to do shell script "perl -wlne 'if (m/(?ims)(^.+disk.+)/) {print \"$1\"}' <<< " & quoted form of myList

# Satimage.osax
set foundLine to find text ".+disk.+" in myList with regexp and string resultwithout case sensitive

# ASObjC Runner
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


Here is a variant :

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
"
--# ASObjC Runner
try
tell application "ASObjC Runner" to item 1 of (look for "^.+disk.+" in myList options "im")
on error
set foundline to ""
end try


Yvan KOENIG (VALLAURIS, France) vendredi 20 avril 2012 20:01:37


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Find text (From: Javi Pérez <email@hidden>)
 >Re: Find text (From: Christopher Stone <email@hidden>)
 >RE: Find text (From: Javi Pérez <email@hidden>)

  • Prev by Date: RE: Find text
  • Next by Date: [ASOC] 'store script' still broken?
  • Previous by thread: RE: Find text
  • Next by thread: [ASOC] 'store script' still broken?
  • Index(es):
    • Date
    • Thread