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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:18:32+00:00 2026-06-10T13:18:32+00:00

Input string: [Wsg-Fs]-A-A-A-Cgbs-Sg7-[Wwg+s-Fs]-A-A-Afk-Cgbs-Sg7 Desired output is a string array: [Wsg-Fs] A A A Cgbs

  • 0

Input string:

[Wsg-Fs]-A-A-A-Cgbs-Sg7-[Wwg+s-Fs]-A-A-Afk-Cgbs-Sg7

Desired output is a string array:

[Wsg-Fs] A A A Cgbs Sg7 [Wwg+s-Fs] A A Afk Cgbs Sg7

If I split the input string with - as delimiter, the string within square brackets also gets split.

How do I split the string such that - within square bracket should be ignored?

I could find some similar posts trying to ignore delimiter enclosed in quotes, however I have not been able to apply those solution to my problem.

Any suggestion would be really helpful. Thanks!

  • 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-10T13:18:33+00:00Added an answer on June 10, 2026 at 1:18 pm

    Assuming there are no nested square brackets, you can use the following to only match - characters that are outside of square brackets:

    -(?![^\[]*\])
    

    Example: http://regex101.com/r/sX5hZ2

    This uses a negative lookahead, with the logic that if there is a closing square bracket before any opening square brackets, then the - that we tried to match is inside of brackets.

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

Sidebar

Related Questions

Sample input string: char *str = 12345.567675; And the desired output if I need
my input String is : 2010-03-24T17:28:50.000Z output pattern is like: DateFormat formatter1 = new
Input String: 115.0000 Output String should be like: 115.00 i used this code: String.format(%.2f,115.0000);
Giving a Input String, the string length will not more than 30, the output
My input string looks like this: 1,724,741,24,527,465,14.00,14.35,14.00,14.25 I want the output to look like
Eg if input string is helloworld I want the output to be like: do
Input String: June 14, 2012 - 01:00:00 UTC Output Local String: Jun 13, 2012
Input: string input = \string1 string2 \; Output: string string2; Check if string has
I am having the input string of Aspen,Colorado-USA I want to split it by
Given an input string, generate an output string where all invalid sequences are either

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.