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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:27:09+00:00 2026-06-14T03:27:09+00:00

can you help me to split a string (or preferred if possible, place a

  • 0

can you help me to split a string (or preferred if possible, place a blank at every “split” occasion) after every change from alphanumeric to numeric and vice versa ?

So a string like D2c1 22 should look like D 2 c 1 22. Best way from would be to put a blank at every change from alpha-numeric to numeric.

  • 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-14T03:27:10+00:00Added an answer on June 14, 2026 at 3:27 am

    Here’s an approach tested with PostgreSQL and verified to work. It’s a bit tortured, so performance might be … interesting.

    CREATE AGGREGATE array_cat_agg (
      BASETYPE = anyarray,
      SFUNC = array_cat,
      STYPE = anyarray
    );
    SELECT array_to_string(array_cat_agg(a), ' ')
    FROM regexp_matches('234kjh23ljkgh34klj2345klj', '(\D*)(\d*)', 'g') x(a);
    

    We need array_cat_agg because regular array_agg can’t aggregate arrays of arrays.

    Alternately, a form of @davidrac’s approach that’ll work with PostgreSQL and probably perform significantly better (though I haven’t tested) is:

    SELECT regexp_replace(
      regexp_replace(
         '234kjh23ljkgh34klj2345klj', '(\d)(\D)', '\1 \2', 'g'
      ), '(\D)(\d)', '\1 \2', 'g');
    

    This is executing the replacement in two passes. First it’s inserting a space where series of digits end and series of non-digits begin. Then in another pass it’s inserting spaces where series of non-digits end and series of digits begin.

    Update: Here’s an improved formulation:

    SELECT trim(regexp_replace('234kjh23ljkgh34klj2345klj', '(?!\d)(\D+)|(?!\D)(\d+)', '\1\2 ', 'g'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to best split csv strings in oracle 9i can you help
Can anyone help me how to split /explode verse format to 3 parts? The
Can someone help me with the correct use of the split function in perl
How can I split a string only once, i.e. make 1|Ceci n'est pas une
How can I write a regex pattern to split a string by a specific
anybody can help me to change that javascript function to AS3? thanks :) function
How can I split string for 3 character? (I don't want to do loop
I want to split string abcdefgh to ab,cd,ef,gh using javascript split() abcdefgh.split(???) Can you
Possible Duplicate: Split string by delimiter, but not if it is escaped I have
How to split and select which is number using regex. User can enter string

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.