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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:35:41+00:00 2026-06-15T18:35:41+00:00

Pattern p = Pattern.compile([\\w\\.]+\\sat\\s[\\w\\.]+); Will match the following three lines from a web page:

  • 0
Pattern p = Pattern.compile("[\\w\\.]+\\sat\\s[\\w\\.]+");

Will match the following three lines from a web page:

dave.andersen at gmail.com
appear at SOSP
staring at now

However, I only want the first line to be matched. Is there a way to specify that there be at least one dot on both sides of at?

  • 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-15T18:35:42+00:00Added an answer on June 15, 2026 at 6:35 pm

    You’ve got the right idea using “+” to indicate at least one, but using “[\w\.]+” matches any string of word characters or periods.

    This will match things like “foo.bar at foo.bar” or “foo….bar at foo..bar”:

    Pattern p = Pattern.compile("\\w+\\.+\\w+\\sat\\s\\w+\\.+\\w+");
    

    This will match things like “foo.bar at foo.bar” or “foo.bar.bar at foo.foo.bar”:

    Pattern p = Pattern.compile("\\w+\\.[\\w\\.]+\\sat\\s\\w+\\.[\\w\\.]+"
    

    The difference between “\w+\.+\w+” and “[\w\.]+” is that the first form will match at least one word character followed by at least one period followed by at least one word character whereas the second form will match any mix up of word characters and periods.

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

Sidebar

Related Questions

I know i can match numbers with Pattern.compile(\\d*); But it doesn't handle the long
In this statement, taken from the Pagerank source code: Pattern.compile(\\[.+?\\]); What does the pattern
Following String causes PatternSyntaxException : Pattern.compile(*\\.*); I want to create a pattern so that
I have this regexp Pattern pattern = Pattern.compile(\\{([^\\}]+)\\}); to match {a1|a2|a3} and {a4} format
How to handle null when using Pattern.compile ? I'm using the following line to
The following code works: String str= test with foo hoo; Pattern pattern = Pattern.compile(foo);
So I have a pattern: hourPattern = re.compile('\d{2}:\d{2}') And match against the compiled pattern
Hi all I have the follow code: Linkify.addLinks(tv, Pattern.compile(http://www.abc.com),http://www.abc.com?m=signup); Problem is I keep getting
I'm trying to understand the following code: Pattern.compile((.*?):) I already did some research about
my application also supports punjabi(\u0A00-\u0A7F) i tried following code Pattern classPattern = Pattern.compile(\u0A00-\u0A7F );

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.