0

I am trying to find the string after the integers in a field but seem to get stuck on the strings part.

Pattern intsOnly = Pattern.compile("\d+");

1000 Stack Overflow ?                      1000 Java Developer Way
                                           1000 Spring Developer Avenue
                                           1000 Stack Overflow Road (this requested)

2000 String  ?                             2000 Integer Creek Way
                                           2000 Float Street
                                           2000 Double Trail
                                           2000 String Way (this requested)

The regex I have here pulls in all the 1000 and 2000 address number records from the field while I need to match at least the first string after the integers.

Requested:

1000 Stack Overflow Road
2000 String Way
5
  • What is your regex and what are you trying to match? Commented May 4, 2017 at 14:56
  • What is the output that you are expecting? Commented May 4, 2017 at 14:56
  • Trying to match on the string after the integer values. Commented May 4, 2017 at 14:56
  • Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. Commented May 4, 2017 at 14:58
  • Could just do (\d+) ([a-zA-Z]+) and get the second group that matches Commented May 4, 2017 at 15:00

2 Answers 2

1

You can define the string part as a group and fetch it like this:

Pattern.compile("\d+ ([a-zA-Z ]+)");
Sign up to request clarification or add additional context in comments.

Comments

0

You can get it with this regex: \d+\s([ \w]+)

Demo on Regex101

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.