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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:19:18+00:00 2026-06-18T04:19:18+00:00

I have searched through-fully all the sides of Stackoverflow and Google, and found nothing

  • 0

I have searched through-fully all the sides of Stackoverflow and Google, and found nothing to help my problem.

Why is it that this code:

if((w.startsWith("\\$", 0) || (w.startsWith("\\$", 1))){
}

and this:

if((w.charAt(0) == '$') || (w.charAt(1) == '$' && w.charAt(0) == ' ')){
}

and this:

 if((w.startsWith("\\$") || (w.startsWith(" \\$"))){
 }

Does not work?

I’m trying to test if a string starts with a dollar sign, or a space and a dollar sign, but for some ODD reason, I can’t seem to find the problem related to the “starts with space” part.

Because the charAt(0) == ‘$’ works just fine… but if I want to test if it starts with a space, then followed by a dollar sign, it doesn’t work.

There are no errors… just nothing happens. Any guidelines/fixes would be extremely appreciated!

  • 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-18T04:19:20+00:00Added an answer on June 18, 2026 at 4:19 am

    There is no need to escape the $ as String.startsWith takes just a normal string as argument, not a regex.

    if (w.startsWith("$") || w.startsWith(" $"))
    

    will suffice.

    If you use String.startsWith(String prefix, int offset) (not required in this case I think) give 0 as offset, not 1 as you have to check from the beginning for a $. It is required if you have to test whether a substring starts with the prefix. In that case, give the beginIndex of substring.

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

Sidebar

Related Questions

I have searched through internet & found that there are no any direct method
I have searched for this, and i found that for api less than 12,
I have searched through threads on Stackoverflow and other sites using the Google machine
I have searched through many times but have not seen this before. Probably really
I have searched this site and Google and even though the idea is pretty
I have an algorithm that searches through all of my sites users, finding those
I have some code that locates all the contact folders that a user has
I have searched online and through my code and I can not figure out
Update, Solved: After all this I found out that I was calling an old
I have searched through for this logic pretty much everywhere but am sure I

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.