Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6766475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:50:07+00:00 2026-05-26T14:50:07+00:00

How to transform with perl this multiline: Colours: Red Green Yellow Blue In: Colours:

  • 0

How to transform with perl this multiline:

Colours:
Red
Green
Yellow
Blue

In:

Colours: Red
Green
Yellow
Blue
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:50:08+00:00Added an answer on May 26, 2026 at 2:50 pm

    The Unicode linebreak grapheme is \R, and is supported from v5.10 onwards.

    You could therefore change the first linebreak to a space in the whole file this way:

    $ perl -Mv5.10 -CSD -i.orig -0777 -pe 's/\R/ /' some_utf8_file.txt
    

    There are other ways that aren’t so wasteful of memory, but they can be tricky to get right. You might omit the -0777 and see whether that is good enough for you in this case.


    EDIT: Regex Escapes

    Here are the escapes supported in regexes, including what release it was first supported in, with release numbers rounded toward even beginning with v5.6.

    Release  Rx Escape   Meaning
    =======  ==========  ===========================================================================================
    v1.0     \0          Match character number zero (U+0000, NULL, NUL).
    v1.0     \0N,\0NN    Match octal character up to octal 077.
    v1.0     \N          Match Nth capture group (decimal) if not in charclass and that many seen, else (octal) character up to octal 377.
    v1.0     \NN         Match Nth capture group (decimal) if not in charclass and that many seen, else (octal) character up to octal 377.
    v1.0     \NNN        Match Nth capture group (decimal) if not in charclass and that many seen, else (octal) character up to octal 377.
    v4.0     \a          Match the alert character (ALERT, BEL).
    v5.0     \A          True at the beginning of a string only, not in charclass.
    v1.0     \b          Match the backspace char (BACKSPACE, BS) in charclass only.
    v1.0     \b          True at Unicode word boundary, outside of charclass only.
    v1.0     \B          True when not at Unicode word boundary, not in charclass.
    v4.0     \cX         Match ASCII control character Control-X (\cZ, \c[, \c?, etc).
    v5.6     \C          Match one byte (C char) even in UTF‑8 (dangerous!), not in charclass.
    v1.0     \d          Match any Unicode digit character.
    v1.0     \D          Match any Unicode nondigit character.
    v4.0     \e          Match the escape character (ESCAPE, ESC, not backslash).
    v4.0     \E          End case (\F, \L, \U) or quotemeta (\Q) translation, only if interpolated.
    v1.0     \f          Match the form feed character (FORM FEED, FF).
    v5.16    \F          Foldcase (not lowercase) till \E, only if interpolated.
    v5.10    \g{GROUP}   Match the named or numbered capture group, not in charclass.
    v5.0     \G          True at end-of-match position of prior m//g or pos() setting, not in charclass.
    v5.10    \h          Match any Unicode horizontal whitespace character.
    v5.10    \H          Match any Unicode character except horizontal whitespace.
    v5.10    \k<GROUP>   Match the named capture group; also \k'NAME', not in charclass.
    v5.10    \K          Keep text to the left of \K out of match, not in charclass.
    v4.0     \l          Lowercase (not foldcase) next character only, only if interpolated.
    v4.0     \L          Lowercase (not foldcase) till \E., only if interpolated.
    v1.0     \n          Match the newline character (usually LINE FEED, LF).
    v5.12    \N          Match any character except newline.
    v5.6     \N{NAME}    Match the named character or named alias, or if outside of charclass named sequence, but only if interpolated and charnames loaded.
    v5.14    \o{NNNNNN}  Match the character given in any number of octal digits.
    v5.6     \p{PROP}    Match any character with the named property.
    v5.6     \P{PROP}    Match any character without the named property.
    v4.0     \Q          Quote (de-meta) metacharacters till \E.
    v1.0     \r          Match the return character (usually CARRIAGE RETURN, CR).
    v5.10    \R          Match any Unicode linebreak grapheme, only outside of charclass.
    v1.0     \s          Match any Unicode whitespace character except \cK.
    v1.0     \S          Match any Unicode nonwhitespace character or \cK.
    v1.0     \t          Match the tab character (CHARACTER TABULATION, HT).
    v4.0     \u          Titlecase (not uppercase) next character only, only if interpolated.
    v4.0     \U          Uppercase (not titlecase) till \E, only if interpolated.
    v5.10    \v          Match any Unicode vertical whitespace character.
    v5.10    \V          Match any character except Unicode vertical whitespace.
    v1.0     \w          Match any Unicode “word” character (alphabetics, digits, combining marks, and connector punctuation)
    v1.0     \W          Match any Unicode nonword character.
    v4.0     \xH         Match the character given in one hex digit.
    v4.0     \xHH        Match the character given in two hex digits.
    v5.6     \x{HHHHHH}  Match the character given in any number of hex.
    v5.6     \X          Match Unicode extended grapheme cluster, only outside of charclass.
    v5.5     \z          True at end of string only.
    v5.0     \Z          True right before optional final newline.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I transform this JSON object: context:{#text:[Most Visited Pages , Hall Residents Advanced
I'd like to transform an URL like this http://www.mydomain.com/it/archive.php=321123 in one like the following
I need to transform my nested sets structure (mysql) into json for this spacetree
I have some text files which I am trying to transform with a Perl
Do I gain something when I transform my $url like this: $url = URI->new(
I think I need some sort of Schwartzian Transform to get this working, but
I'm using Perl's XML::Twig module to transform XML into (X)HTML. I need to output
Trying to run this little perl program from parsCit: parsCit-client.pl e1.txt Too late for
How do I transform this to haml? <div class=alert alert-<%= name == :notice ?
I have a Perl script that contains this code snippet, which calls the system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.