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

  • Home
  • SEARCH
  • 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 7653041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:55:31+00:00 2026-05-31T11:55:31+00:00

I have the next text aaa|bbbb|cccc|dddd\|eeee|ffff and i want to split by | and

  • 0

I have the next text

 aaa|bbbb|cccc|dddd\|eeee|ffff

and i want to split by | and excluding when | is preceded by \ and obtain

aaa

bbbb

cccc

dddd\|eeee

ffff

Thanks.

ps : i tried using some regexp generator (for example http://txt2re.com/ ) but frankly regexp is anything but friendly.

update: finally i give up. Regexp is not fast (i did a benchmark), neither is clear (in comparison with a function that everybody can follow), then i skip it and now i am using real code.

  • 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-31T11:55:32+00:00Added an answer on May 31, 2026 at 11:55 am

    Tried to add this as a comment to eyelidlessness’s answer, but don’t know how to format it there…

    Anyhow, eyelidlessness answer looks correct to me:

        String str = "aaa|bbbb|cccc|dddd\\|eeee|ffff";
        String[] tokens = str.split("(?<!\\\\)\\|");
        System.out.println(Arrays.toString(tokens));    
    

    which prints:

    [aaa, bbbb, cccc, dddd\|eeee, ffff]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form with multiple input type=radio with text next to them. I want
I have the next code: Process p = Runtime.getRuntime().exec(args); and I want my program
I have the next code: b.Text = myDataContext.purchases.Count().ToString(); the b is label that i
I want to declare next type: <partCode negation=true|false>\*|[0-9]{1,9}</name> with boolean attribute, and text-only content,
In php I have next text: $text='<div id=my_date_div year=2010 month=12 day=07 hour=00 minute=00 >
I have the next input element: <input type=text name=username id=username value=user name helper=formText defvalue=user
I have next HTML: <input type=text id=search name=searchword value= /> <ul id=search_list> <li>first</li> <li>second</li>
I have a button next to a text box and when I click the
I have next tables Order , Transaction , Payment . Class Order has some
I'm going to start of by noting that I have next to no python

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.