On 06/01/2021, at 18:59, Howard <[email protected] 
<mailto:[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 
<http://regex101.com/> will give you more information and more explanation.

See your patter here:

https://regex101.com/r/eUm1Fo/1 <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/95FE0CE0-CDBE-4044-A1CB-C4FAD1A7F1A2%40gmail.com.

Reply via email to