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 Jourdain
On Tuesday, June 1, 2021 at 4:15:09 PM UTC+2 Neil Faiman wrote:

> On Jun 1, 2021, at 9:11 AM, Howard <[email protected]> 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 
> are extracted from. How can I do that?
>
> Howard
>
> *Examples*
> 1001405001
> 0000(10)0000
> 001320000001
> 0(16)5000000
> 021(10)0000(11)
> 010101000
>
>
> There is likely a simpler way, but here is an easy three step process.
>
> 1. Text > Add/Remove Line Numbers... . Select “Insert”, check “Include 
> space after number”:
>
> 1 1001405001
> 2 0000(10)0000
> 3 001320000001
> 4 0(16)5000000
> 5 021(10)0000(11)
> 6 010101000
>
>
> 2. Text > Process Lines Containing... . Search string “\(\d+\)”. Check 
> “Grep”, “Copy to new document”:
>
> 2 0000(10)0000
> 4 0(16)5000000
> 5 021(10)0000(11)
>
>
> 3. Command-F (or Search > Find....). Search string “[ )]\d*\(?”. 
> Replacement string ” ” (a single space). Check “Grep”.Click “Replace All”.
>
> 2 10 
> 4 16 
> 5 10 11 
>
>
> In the result, each line contains a line number and one or more 
> parenthesized numbers, separated by spaces.
>
> Explanation of the grep search: You want to keep the initial line number 
> and the parenthesized numbers, and remove everything else, replacing it by 
> spaces. The search string is a description of an “everything else”:
>
> *“[ )]”– A*n “everything else” begins with a space (which must be the 
> space following the line number, since those are the only spaces in the 
> file) or the closing parenthesis of a parenthesized number.
> *“\d+”* — The string of contiguous digits following the space or closing 
> parenthesis are an “everything else” number.
> *“\(?”* — The “everything else” number is either at the end of the line 
> or it is followed by the opening parenthesis of a parenthesized number. So 
> if it is followed by an opening parenthesis, then that is part of the 
> “everything else”, too.
>
> Regards,
>
> Neil Faiman
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/4a21cce3-bdc3-4a50-bb49-78008ceadaa7n%40googlegroups.com.

Reply via email to