Re: Extract number within parentheses using GREP

2021-06-07 Thread Christopher Stone
On 06/07/2021, at 14:53, Christopher Stone wrote:This becomes terribly tedious when you do it all by hand, so I wrote you an example Text Factory.Install here:~/Library/Application Support/BBEdit/Text Filters/Text Factories/You have to run it from the Text > Apply Text

Re: Extract number within parentheses using GREP

2021-06-07 Thread Christopher Stone
On 06/03/2021, at 09:46, Howard wrote:Chris, what you wrote is very helpful.To get the Grep results not enclosed in parentheses, I used the Replace pattern `\2` with this Search pattern:\d*(\((\d+)\))\d*but that resulted in these numbers:10161011Hey Howard,That can't be

Re: Extract number within parentheses using GREP

2021-06-03 Thread jj
Hi Howard, You can use this regex in the Find field: \d*(?:\((\d+)\))?\d*(?:\((\d+)\))?\d*(?:\((\d+)\))?\d*(?:\((\d+)\))?\d*(?:\((\d+)\))?\d* with this in the Replace field: \1 \2 \3 \4 \5 It can find from 1 to 5 parentheses. Repeat the (?:\((\d+)\))?\d* pattern and the corresponding

Re: Extract number within parentheses using GREP

2021-06-03 Thread Howard
Chris, what you wrote is very helpful. To get the Grep results not enclosed in parentheses, I used the Replace pattern `\2` with this Search pattern: \d*(\((\d+)\))\d* but that resulted in these numbers: 10 16 10 11 Given that the last two numbers, 10 and 11, are on the same line, is there a

Re: Extract number within parentheses using GREP

2021-06-02 Thread Christopher Stone
On 06/01/2021, at 18:59, Howard mailto:leadwithlo...@gmail.com>> wrote: > To help me to understand better the Grep part of Neil's solution, can someone > provide me with the search pattern and the replace pattern to just find those > lines with numbers in parentheses and extract them without any

Re: Extract number within parentheses using GREP

2021-06-01 Thread Tom Robinson
On 2021-06-02, at 11:59, Howard wrote: > > Thanks everyone for the responses. > > To help me to understand better the Grep part of Neil's solution, can someone > provide me with the search pattern and the replace pattern to just find those > lines with numbers in parentheses and extract them

Re: Extract number within parentheses using GREP

2021-06-01 Thread Howard
Thanks everyone for the responses. To help me to understand better the Grep part of Neil's solution, can someone provide me with the search pattern and the replace pattern to just find those lines with numbers in parentheses and extract them without any line numbers? I'd like to put that into

Re: Extract number within parentheses using GREP

2021-06-01 Thread Christopher Stone
On 06/01/2021, at 08:11, Howard mailto:leadwithlo...@gmail.com>> wrote: > I have a set of numbers. Within some of them is at least one number within > parentheses. I need to find all the lines containing numbers within > parentheses and extract those numbers. I also need to know which line they

Re: Extract number within parentheses using GREP

2021-06-01 Thread jj
Here is Neil 3 step process as one text filter ```sh #!/usr/bin/env sh perl -pe '$_ = "$.:$_"' | perl -ne 'print if /\(/' | perl -pe 's/\d*\((\d*)\)\d*/ \1/g' # add line number # keep only lines containing a '(' # ouput only digits enclosed in parenthesis ``` Regards, Jean

Re: Extract number within parentheses using GREP

2021-06-01 Thread Neil Faiman
On Jun 1, 2021, at 9:11 AM, Howard mailto:leadwithlo...@gmail.com>> wrote: > > I have a set of numbers. Within some of them is at least one number within > parentheses. I need to find all the lines containing numbers within > parentheses and extract those numbers. I also need to know which line

Extract number within parentheses using GREP

2021-06-01 Thread Howard
I have a set of numbers. Within some of them is at least one number within parentheses. I need to find all the lines containing numbers within parentheses and extract those numbers. I also need to know which line they are extracted from. How can I do that? Howard *Examples* 1001405001