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 way to modify the Grep expression so that the results appear with the 
final two numbers on the same line, as shown below, with a space separating 
them?
10
16
10 11

Howard


On Wednesday, 2 June 2021 at 5:37:42 am UTC-4 [email protected] wrote:

> On 06/01/2021, at 18:59, Howard <[email protected]> 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 
> line numbers? I'd like to put that into the Pattern Playground and work 
> with that a bit.
>
> ------------------------------
>
> Hey Howard,
>
> Assuming all of your data lines are variations of this format:
>
> 1001405001
> 0000(10)0000
> 001320000001
> 0(16)5000000
> 021(10)0000(11)
> 010101000
>
> Then it's extremely simple to extract the lines.
>
> Find:
>
> *.*\(\d+\).**
>
> .*   ==  any character zero or more.
> \(   ==  literal open parenthesis.
> \d+  ==  any digit one or more.
> \)   ==  literal close parenthesis.
> .*   ==  any character zero or more.
>
> ------------------------------
>
> If I *knew* that any line containing even 1 parenthesis was viable for 
> extraction I could be lazy and do:
>
> Find:
>
> *.*\(.**
>
> .*   ==  any character zero or more.
> \(   ==  literal open parenthesis.
> .*   ==  any character zero or more.
>
> OR
>
> You could use Neil's suggestion of Process-Lines-Containing with just 1 
> literal parenthesis.
>
> ------------------------------
>
> Now – to remove the unwanted digits:
>
> Find:
>
> *\d*(\(\d+\))\d**
>
> \d*  ==  any digit zero or more.
> (    ==  start capture group.
> \(   ==  literal parenthesis.
> \d+  ==  any digit 1 or more.
> \)   ==  literal parenthesis.
> )    ==  close capture group.
> \d*  ==  any digit zero or more.
>
> Replace:
>
> *\1*
>
> \1   ==  capture group 1.
>
> ------------------------------
>
> As I've mentioned BBEdit is always my starting point for building regular 
> expressions, but there are times when a tool like RegEx101.com will give 
> you more information and more explanation.
>
> See your patter here:
>
> https://regex101.com/r/eUm1Fo/1
>
> --
> Best Regards,
> Chris
>
>

-- 
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/976c251a-0da7-4520-b104-1566fd103201n%40googlegroups.com.

Reply via email to