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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:41:08+00:00 2026-05-26T19:41:08+00:00

For some reason I am unable to get the pattern match for preference_network_ followed

  • 0

For some reason I am unable to get the pattern match for “preference_network_” followed by any anything else as a single string. I want to be able to test if a preference key contains “preference_network_” using the key.matches() method. How can I get this working, I’ve tried a few things with no success. Thanks is advance.

UPDATE

Sorry for not clarifying. All of these solutions I can perform and know about. What I am trying to do is use the “key.matches(String regularExpression)” function where key is a parameter to the onSharedPreferenceChangeListener method. This is what I am having trouble to get working.

And I’m aware I do not have to use this, I can use the startsWith just fine. I was just wondering.

Thanks

  • 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-26T19:41:08+00:00Added an answer on May 26, 2026 at 7:41 pm

    solutions without using patterns:

    str.startsWith("preference_network_");
    str.contains("preference_network_");
    

    With patterns

    // the same as contains.
    Pattern p = Pattern.compile("preference_network_");
    p.matcher(str).find(); 
    
    // the same as startsWith.
    Pattern p = Pattern.compile("^preference_network_");
    p.matcher(str).find(); 
    

    If you want to use matches() you have to writer full pattern:

    Pattern p = Pattern.compile("^preference_network_.*");
    p.matcher(str).matches(); 
    

    Because matches performs as if your pattern starts with ^ and ends with $, i.e.

    Pattern.compile("^something$").matcher(str).find() is the same as Pattern.compile("something").matcher(str).matches()

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

Sidebar

Related Questions

For some reason Im unable to get the submit button below to re-enable once
For some reason I am unable to read any cookies from my CakePHP app
I am unable to get my sessions captcha to work for some reason. This
For some reason, no matter how I go about it, I cannot get TortoiseSVN
I need something real simple, that for some reason I am unable to accomplish
Hi guys for some weird reason I'm unable to send email using zend mail
I'm trying to get lein up and running. But for some reason I'm having
For some reason I am unable to use query results in the same function
For some reason, my ability to attach a debugger to ANYTHING has just stopped.
For some reason I never see this done. Is there a reason why not?

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.