• 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: Using perl to extract tagged text - again
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using perl to extract tagged text - again


  • Subject: Re: Using perl to extract tagged text - again
  • From: deivy petrescu <email@hidden>
  • Date: Thu, 4 May 2006 21:21:34 -0400


On May 4, 2006, at 16:19, Eric Geoffroy wrote:

Hi,

Quick followup if you don't mind. I tried the sed script and the perl script. Strange results.

echo "
<center><br>
<h2>The password for 'pub' has been set to: <pre>wfi79rJy</pre></h2>
<br>
<br>
</center>" | sed -ne 's,<pre>\(.*\)</pre>,\1,p'

RESULT: <h2>The password for 'pub' has been set to: wfi79rJy</h2>

The perl script: perl -pe 'BEGIN {undef $/;} print $1 while m|<pre> (.*?)</pre>|ms'

RESULT: 79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJyw fi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJ ywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79 rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJywfi79rJy^C
and so on.


My homegrown perl, chops off part of the password.

perl -nle 'print $1 while /\<pre\>([^\<pre\>"]*)/g'

RESULT: wfi79


- Eric


I apologize for writing this readable and working code in an Applescript list, but:
<script>
set ttext to "
<center><br>
<h2>The password for 'pub' has been set to: <pre>wfi79rJy</pre></h2>
<br>
<br>
</center>"
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "<pre>"
set ttext to text item 2 of ttext
set AppleScript's text item delimiters to "</pre>"
set ttext to text item 1 of ttext
set AppleScript's text item delimiters to tid
ttext
--> "wfi79rJy"
</script>


You can simplify the code, but the message is loud and clear.

Deivy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Using perl to extract tagged text - again (From: Eric Geoffroy <email@hidden>)
 >Re: Using perl to extract tagged text - again (From: "Mark J. Reed" <email@hidden>)
 >Re: Using perl to extract tagged text - again (From: Eric Geoffroy <email@hidden>)

  • Prev by Date: Re: Re script
  • Next by Date: Re: A better way to get web data?
  • Previous by thread: Re: Using perl to extract tagged text - again
  • Next by thread: Re script
  • Index(es):
    • Date
    • Thread