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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:50:51+00:00 2026-06-12T11:50:51+00:00

In Java I am using Pattern and Matcher to find all instances of .A

  • 0

In Java I am using Pattern and Matcher to find all instances of “.A (a number)” in a set of strings to retrieve the numbers.

I run into problems because one of the words in the file is “P.A.M.X.” and the number returns 0. It won’t go through the rest of the file. I’ve tried using many different regular expressions but I can’t get past that occurrence of “P.A.M.X.” and onto the next “.A (number)”

for (int i = 0; i < input.size(); i++) {

Pattern pattern = Pattern.compile("\\.A\\s\\d+");
Matcher matcher = pattern.matcher(input.get(i));

while (matcherDocId.find())
    {   
            String matchFound = matcher.group().toString();
            int numMatch = 0;
            String[] tokens = matchFound.split(" ");
            numMatch = Integer.parseInt(tokens[1]); 
            System.out.println("The number is: " + numMatch);
    }
}
  • 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-12T11:50:53+00:00Added an answer on June 12, 2026 at 11:50 am

    Short sample for you:

    Pattern pattern = Pattern.compile("\\.A\\s(\\d+)"); // grouping number
    Matcher matcher = pattern.matcher(".A 1 .A 2 .A 3 .A 4 *text* .A5"); // full input string
    while (matcher.find()) {
        int n = Integer.valueOf(matcher.group(1)); // getting captured number - group #1
        System.out.println(n);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Pattern and Matcher classes from Java to parse a link file
So i am writing my first Java application using MVP pattern. One of MVPs
I trying to implement the active record pattern using Java/JDBC and MySQL along with
I tried writing a program in Java using regex to match a pattern and
I have a problem with Observer-Pattern and deadlock using threads. package observerDeadLock; import java.util.Observable;
I tried this regex in Java : Pattern orderCheck = Pattern.compile("^([\\-\\+])?(created|title|price|creation)$", Pattern.CASE_INSENSITIVE); orderCheck.matcher(value).matches(); And
I want to using regex on Java to split a number string. I using
Using java.util.regex.Pattern.compile() you can specify a pattern as parameter. But how can you specify
Been going crazy with ANDROID's regex using the pattern / matcher methods. I've been
I'm implementing a keyword highlighter in Java. I'm using java.util.regex.Pattern to highlight (making bold)

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.