I have 1. LoremHe he he% not sure spelling2. Lorem ipsunI want to have\textbf{1. Lorem}He he he% not sure spelling\textbf{2. Lorem}ipsunMy pseudocode attemptperl -000pe 's/\n\n\d./; s/\n\d.\n\\textbf\{ /g; s/$/\}/'which is based on my two previous questions about regex here.I try to match the thing which starts with a number.Replace the beginning of the match and the end of the match.The code gives meBackslash found where operator expected at -e line 1, near s/\n\n\d./; s/\Backslash found where operator expected at -e line 1, near n\Backslash found where operator expected at -e line 1, near n\Backslash found where operator expected at -e line 1, near textbf\Backslash found where operator expected at -e line 1, near $/\    (Missing operator before \?)syntax error at -e line 1, near s/\n\n\d./; s/\Execution of -e aborted due to compilation errors.How can you bold the given text?
To bold one line with Perl regex
regular expression;perl
Since the -000 makes each paragraph into a line, you can use the classic regular expression anchors (^ and $) to match the beginning and end of each line. So, in your case, all you need is:$ perl -000pe 's/^(.+)\n/\\textbf{$1}\n/;' file \textbf{1. Lorem}He he he\textbf{2. Lorem }ipsunNote that the \ needs to be escaped (\\), that's because \ is a special character used to escape others so you also need to use it to escape itself.If you can have comments as the first line of a paragraph, then this approach fails and you need to bold all lines that start with a number:perl -pe 's/^\d\..+/\\textbf{$&}/' file