Re: Extract string found in line

2014-05-13 Thread Christopher Stone
On May 12, 2014, at 11:08, Lee Hinde leehi...@gmail.com wrote:
 The longer string is like this:
__

Hey Lee,

That makes it much easier.

This filter will remove all text except for what you want.

#! /usr/bin/env perl 
use v5.010; use strict; use warnings;

while () {
say $1 if ( m!.*(GET /public/search/\?q=(\w|\+|\.|-)+).*! );
}

The regex is between the two exclamation points and can be altered to suit.

Save the filter here:

~/Library/Application Support/BBEdit/Text Filters

Access via the menu {Text}--{Apply Text Filter}

These are fast, flexible, and efficient.

I give often-used filters a keyboard shortcut, and I have a Keyboard Maestro to 
actually open the {Apply Text Filter} menu from whence I can type-select to 
access the filter I want.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
You received this message because you are subscribed to the Google Groups 
BBEdit Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Extract string found in line

2014-05-13 Thread Christopher Stone
On May 12, 2014, at 14:30, Lewis Kirk goo...@dmzgraphics.com wrote:
 
 Here's a little Applescript snippet that works in BBEdit:
 ...
 Don't know if it works in anything else.
__

Hey Lewis,

BBEdit's AppleScript syntax is BBEdit-specific, but it will most often work in 
TextWrangler by simply changing to tell application TextWrangler.  (Except 
when a function that's available in BBEdit isn't available in TextWrangler.)

Here's a turnkey snippet for Lee's task:

---
tell application BBEdit
  tell front text window
replace .*(GET /public/search/\\?q=(\\w|\\+|\\.|-)+).* using \\1 
options {search mode:grep, case sensitive:false, starting at top:true}
  end tell
end tell
---

Unlike the Perl filter I posted it will leave lines that don't match the 
regular expression intact.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
You received this message because you are subscribed to the Google Groups 
BBEdit Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Extract string found in line

2014-05-12 Thread Lee Hinde
The longer string is like this:

 - [27/Mar/2014:11:06:59 -0700] GET /public/search/?q=lunch+time+boot+vamp
HTTP/1.1 200 18045 http://www.example.com/public/minion/edit/177304;
Mozilla/5.0 (Linux; U; Android 4.3; en-us; SCH-I535 Build/JSS15J)
AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30


On Sun, May 11, 2014 at 9:05 PM, Christopher Stone 
listmeis...@suddenlink.net wrote:

 On May 11, 2014, at 14:36, Lee Hinde leehi...@gmail.com wrote:
  I am parsing apache log files. This is the grep pattern I'm using:
 
  GET /public/search/\?q=(\w|\+|\.|-)+
 __

 Hey Lee,

 When making these kinds of requests it's always better if you provide an
 actual sample of the data you're working with.

 Just looking at it I could say:

 Find:

 .*(GET /public/search/\?q=(\w|\+|\.|-)+).*

 Replace:

 \1

 But I'd much rather see the data and actually test my solution.

 For that matter this seems like a job for a Perl filter.

 --
 Best Regards,
 Chris

 --
 This is the BBEdit Talk public discussion group. If you have a
 feature request or would like to report a problem, please email
 supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit

 ---
 You received this message because you are subscribed to the Google Groups
 BBEdit Talk group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to bbedit+unsubscr...@googlegroups.com.
 To post to this group, send email to bbedit@googlegroups.com.


-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
You received this message because you are subscribed to the Google Groups 
BBEdit Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Extract string found in line

2014-05-12 Thread Lewis Kirk
Here's a little Applescript snippet that works in BBEdit:

find src=\([a-zA-Z0-9\\=\\\.\\-_]+)/([a-zA-Z0-9\\=\\\.\\-_]+)\ searching 
in imgDocRef options {search mode:grep, starting at top:false} with selecting 
match

set imgSrc to grep substitution of \\1
set imgName to grep substitution of \\2

Don't know if it works in anything else.

On May 11, 2014, at 3:36 PM, Lee Hinde wrote:

 I am parsing apache log files. This is the grep pattern I'm using:
 
 GET /public/search/\?q=(\w|\+|\.|-)+
 
 works fine. But I want to extract just the text that matches that string and 
 lose all the rest of the line.
 
 How would I do that?
 
 -- 
 This is the BBEdit Talk public discussion group. If you have a 
 feature request or would like to report a problem, please email
 supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit
 
 --- 
 You received this message because you are subscribed to the Google Groups 
 BBEdit Talk group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to bbedit+unsubscr...@googlegroups.com.
 To post to this group, send email to bbedit@googlegroups.com.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
You received this message because you are subscribed to the Google Groups 
BBEdit Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Extract string found in line

2014-05-11 Thread Lee Hinde
I am parsing apache log files. This is the grep pattern I'm using:

GET /public/search/\?q=(\w|\+|\.|-)+

works fine. But I want to extract just the text that matches that string
and lose all the rest of the line.

How would I do that?

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
You received this message because you are subscribed to the Google Groups 
BBEdit Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Extract string found in line

2014-05-11 Thread Christopher Stone
On May 11, 2014, at 14:36, Lee Hinde leehi...@gmail.com wrote:
 I am parsing apache log files. This is the grep pattern I'm using:
 
 GET /public/search/\?q=(\w|\+|\.|-)+
__

Hey Lee,

When making these kinds of requests it's always better if you provide an actual 
sample of the data you're working with.

Just looking at it I could say:

Find:

.*(GET /public/search/\?q=(\w|\+|\.|-)+).*

Replace:

\1

But I'd much rather see the data and actually test my solution.

For that matter this seems like a job for a Perl filter.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
You received this message because you are subscribed to the Google Groups 
BBEdit Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.