Grepping variable in BBedit?

Hi,

I’ll freely admit I’m a tard with AS, a complete novice, so please indulge me for a moment if the answer to this is simple as can be.

I’m trying to include the results of a previous BBedit find in a new grep find, basically this:
find [grep code] – this part’s easy enough
set Variable to selection – works
find “[grep code]” & Variable – doesn’t work properly

What I’m trying to do is search for a specific string in one page, and find that string as part of a href in another, and select the entire href.

Any ideas? Thanks for your help…

beertigger

With the following text in window 1:

and this in window 2:

If I run this script:

tell application "BBEdit"
	set s_text to "[^ ]+.jpg"
	set s_options to {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
	if found of (find s_text searching in text window 1 options s_options with selecting match) then
		set found_text to contents of selection
		set s_text to "(<a href=\"" & found_text & "[^>]+>)"
		find s_text searching in text window 2 options s_options with selecting match
	else
		beep 
	end if
end tell

It selects ‘image.jpg’ in window 2.

Jon

http://www.anybrowser.org/bbedit/grep.shtml#SavingPats
BBedit grep search tutorial for further study.
SC

Thanks jonnB,

I think my initial lack of success may have had something to do with having “match words: true.”

Anyway, a bunch of funking around, and I’ve got a script that updates a page of html in about 3 seconds that used that take upwards of an hour. Which seems to leave me more time to write another script to save some more time… and so on.

beertigger