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 8129179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:12:13+00:00 2026-06-06T08:12:13+00:00

I have a huge string (22000+ characters) of encoded text. The code is consisted

  • 0

I have a huge string (22000+ characters) of encoded text. The code is consisted of digits [0-9] and lower case letters [a-z]. I need a regular expression to insert a space after every 4 characters, and one to insert a line break [\n] after every fourty characters. Any ideas?

  • 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-06-06T08:12:14+00:00Added an answer on June 6, 2026 at 8:12 am

    Well, a regexp in itself doesn’t insert a space, so I’ll assume you have some command in whatever language you’re using that inserts based on finding a regexp.

    So, finding 4 characters and finding 40 characters: that’s not pretty in general regular expressions (unless your particular implementation has nice ways to express numbers). For finding 4 characters, use

    ....
    

    Because typical regexp finders use maximal munch, then from the end of one regexp, search forward and maximally munch again, that’ll chunk your string into 4 character pieces. The ugly part is that in standard regular expressions, you’ll have to use

    ........................................
    

    to find chuncks of 40 characters, although I’ll note that if you run your 4 character one first, you’ll have to run

    ..................................................
    

    or

    .... .... .... .... .... .... .... .... .... .... 
    

    to account for the spaces you’ve already put in.

    The period finds any characters, but given that you’re only using [0-9|a-z], you could use that regexp in place of each period if you need to ensure nothing else slipped in, I was just avoiding making it even more gross.

    As you may be noting, regexp have some limitations. Take a look at the Chomsky hierarchy to really get into their theoretical limitations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge string that looks like this: Text Text Text Text Text
Hi i have a following huge string format example format : p= --0016367d537a47795e0489ecb3c7\nContent-Type: text/plain;
I have a huge file of code with many lines like this: Enterprise::TextMessageBox::Show(String::Format(SВъзникнал е
I have a huge string of raw text that is about 200,000 words long.
I have a huge string of text that is apparently raw data for a
I have a huge string. I need to extract a substring from that that
I have huge data which is static. I need to save it within the
I have a huge MySQL table which has its rows encoded in UTF-8 twice.
I have a huge binary string, like: 1110 0010 1000 1111 0000 1100 1010
Language: C# I have to pass a huge string array (built dynamically) as an

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.