Something like this should do the trick. The expression in the first set parentheses finds the paragraphs you are targeting. The start of a line ^ followed by your target text and everything up to the next new-line \n. The expression in the second set of parentheses finds the following paragraph. The replacement pattern inserts the new text you need between them so it prefixes the second paragraph.
Search: (^Art\..*?\n+)(.*?$) Replace: \1_A\2 Art. One First paragraph Second paragraph Art. Two First paragraph Second paragraph Becomes Art. One _AFirst paragraph Second paragraph Art. Two _AFirst paragraph Second paragraph The Pattern Playground on the Search menu is pretty useful for playing around with these expressions. Hope this helps, [fletcher] > On May 21, 2020, at 1:53 AM, Adriano Borgobello <borgobe...@gmail.com> wrote: > > In a plain text file, how can I replace or insert a string at the starting of > a paragraph, knowing a substring in the previous paragraph?! > I try to explain with an example. > I have hundreds of paragraphs that start with the substring "¶Art. " and > continues with different text. I need to insert a new substring "¶_A" at the > head of all paragraphs that follows the above, but only at the first (there > are undefined number of paragraphs after each "¶Art. " starting paragraph. > I say insert or replace, because I guess I can replace newline char with > newline + "¶_A". > > > -- > 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 here. Follow @bbedit on Twitter: > <https://twitter.com/bbedit <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 > <mailto:bbedit+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/bbedit/522a82e0-4224-415f-803d-dd9862d7d0f0%40googlegroups.com > > <https://groups.google.com/d/msgid/bbedit/522a82e0-4224-415f-803d-dd9862d7d0f0%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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 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 bbedit+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/2AEA6A70-5E19-4D00-A7D5-507E543E2BDB%40cumuli.com.