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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:51:00+00:00 2026-06-05T13:51:00+00:00

I want to get the input String splitted by a colon. For example, a:int

  • 0

I want to get the input String splitted by a colon. For example, a:int. I can use [^:]* to get the a and int.

However, I don’t want the String to be split by any combination which includes colon, such as A:=3:command. What I want are the A:=3 and command but not A, =3, command.

Could someone tell me how to write the regular expression?

  • 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-05T13:51:02+00:00Added an answer on June 5, 2026 at 1:51 pm

    I’m going to assume, pending an edit by the OP, that the only colons that should appear in a split are those followed by simple ASCII letters or numbers. The solution can easily be generalized.

    Here is a concrete example in JavaScript:

    s = "x:=3:comment"
    s.split(/:(?=[\s\w])/)
    

    The result is

    ['x:=3','comment']
    

    The split function says “split on colons that are followed by spaces or word characters (ASCII letters or numbers or underscores)”.

    Other languages have more powerful forms of lookaround (in particular negative lookarounds), but the basic idea is to construct a regex where the split value is a colon in a particular context.

    ADDENDUM

    Another example:

    "this:has:(some%:   7colons:$:6)".split(/:(?=[\s\w])/)
    

    produces:

    ['this','has:(some%','   7colons:$','6')]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to simply get the user to input a number. I can get
If I have this input string: {post:[matt]} and I want to get the string
I want to encrypt string to base64, the string input can be in differential
These are two type of string I can get in input: String mex1 =
In a particular example, I want to extract function calls in a string input
I want to get a generic input to my function. I tried interface IReport
I want to get the value of another textbox and input it in realtime
I have <input type=file id=basicUploadFile multiple=multiple> and I want to get all file names
i want get weather from http://www.google.com/ig/api?weather= I use this // load xml result from
What I want to do is replace the "[replace]" in input string with the

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.