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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:11:50+00:00 2026-05-13T21:11:50+00:00

I’m trying to find a good way to get a Scanner to use a

  • 0

I’m trying to find a good way to get a Scanner to use a given delimiter as a token. For example, I’d like to split up a piece of text into digit and non-digit chunks, so ideally I’d just set the delimiter to \D and set some flag like useDelimiterAsToken, but after briefly looking through the API I’m not coming up with anything. Right now I’ve had to resort to using combined lookaheads/lookbehinds for the delimiter, which is somewhat painful:

scanner.useDelimiter("((?<=\\d)(?=\\D)|(?<=\\D)(?=\\d))");

This looks for any transition from a digit to a non-digit or vice-versa. Is there a more sane way to do this?

  • 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-13T21:11:50+00:00Added an answer on May 13, 2026 at 9:11 pm

    EDIT: The edited question is so different, my original answer doesn’t apply at all. For the record, what you’re doing is the ideal way to solve your problem, in my opinion. Your delimiter is the zero-width boundary between a digit and a non-digit, and there’s no more succinct way to express that than what you posted.

    EDIT2: (In response to the question asked in the comment.) You originally asked for an alternative to this regex:

    "((?<=\\w)(?=[^\\w])|(?<=[^\\w])(?=\\w))"
    

    That’s almost exactly how \b, the word-boundary construct, works:

    "(?<=\\w)(?!\\w)|(?<!\\w)(?=\\w)"
    

    That is, a position that’s either preceded by a word character and not followed by one, or followed by a word character and not preceded by one. The difference is that \b can match at the beginning and end of the input. You obviously didn’t want that, so I added lookarounds to exclude those conditions:

    "(?!^)\\b(?!$)"
    

    It’s just a more concise way to do what your regex did. But then you changed the requirement to matching digit/non-digit boundaries, and there’s no shorthand for that like \b for word/non-word boundaries.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

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.