> On Jan 3, 2020, at 13:15, anotherhoward <writerhow...@gmail.com> wrote:
> 
> Here is my input:
> 1
> 2
> 3
> 4
> 5
> 
> Here is my search pattern:
> \d\n
> 
> Here is the desired output:
> 1,2,3,4,5

So, you need to "separate" the number part from the line break part, so that 
you can keep the number part in the replacement string but replace the line 
break part with a ",".

When you check the manual, there is a "Creating subpatterns" section and it 
says  

"Subpatterns provide a means of organizing or grouping complex grep patterns. 
This is primarily important for two reasons: for limiting the scope of the 
alternation operator (which otherwise creates an alternation of everything to 
its left and right), and for changing the matched text when performing 
replacements."

In all honesty, that's not very clear, plus it can lead to wrong 
interpretations, because, generally speaking, you create subpatterns so that 
you can call them in the replacement (and not to change them). The paragraph 
should probably have "and for *remembering* the matched text when performing 
replacements." instead.

But the point is, you need that subpattern here:

instead of \d\n, try (\d)\n

now, the \d part is remembered.

And you can call it in the replacement string by "Using Backreferences in 
Subpatterns", which is the following section in the manual.

Here, you only have one subpattern: (\d)\n

So, to call it in the replacement string, you just use \1, now, for every \d 
match, \1 will use the number that matched that \d.

Last, you want to really replace "\n" with ",", which is trivial.

So your replacement string should be:

\1,


Search for: (\d)\n
Replace with: \1,



Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune


-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/C881BBFF-D870-4F2F-BB24-036C29991682%40traduction-libre.org.

Reply via email to