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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:44:59+00:00 2026-05-23T04:44:59+00:00

I have a small Problem using reg. expressions with scanner here’s the code: String

  • 0

I have a small Problem using reg. expressions with scanner

here’s the code:

String name;
    Pattern p = Pattern.compile("\\s+|\\W+|\\_+");
    ArrayList<String> reay = new ArrayList<String>(1000);
    try {
        Scanner asdf = new Scanner(new File(s)).useDelimiter(p);
        while (asdf.hasNext()) {
            name = asdf.next();
            reay.add(name);

        }
        asdf.close();
    }

and the resulting array (using a lot of non-word chars in the text file):

[arst, , tdnxc, , rst, , arst, , arst, wfp, arst, , arst]

not sure what I’m missing and why I get whitespace entries in my array

  • 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-23T04:45:00+00:00Added an answer on May 23, 2026 at 4:45 am

    Your regex matches one or more whitespaces, then OR one or more nonwords, then OR one or more underscores.

    So for an input of ” $_” it will say, space is a match! Capture what’s before next delimiter… $ is a match! Return empty string between space and $. Capture what’s before next delimiter.. _ is a match! return empty string between $ and _.

    I think you meant for your delimiter to be:

    [\\s\\W_]+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem with interfaces. Here it is in Pseudo code :
I have a small problem in my code. I'm using fetch_assoc to get data
Now I create a small PHP Application, here I have problem for using file
Hi i have a small problem , iam using join to get some names
I have a small problem, but I'm a bit stumped. I am using the
i'm having a small problem here. I'm using a simple rule to redirect all
I have small problem with name spaces in php 5.3. I've made declaration for
Hi I have a small problem in my ANTLR tree grammar. I am using
I have a small problem here. I want to list my files from a
I'm having a small problem with embedForm using doctrine and SF1.4 I have created

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.