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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:52:13+00:00 2026-06-06T00:52:13+00:00

Having another tough one here guys, basically I would like to check if a

  • 0

Having another tough one here guys, basically I would like to check if a string contains the word “Foo” and if it does contain it, does it start with it? If it does start with Foo, it should be the only Foo that starts with a capital, all others should be small letters.

If the above criteria is met, it should return true.

If the string contains Foo but doesn’t start with Foo, it should immediately return false since you cant have a capital Foo in the middle of the string.

In the event that said string contains foo, but doesn’t start with Foo, all instances of foo should be lowercase. If this criteria is met, return true.

I should mention i am looking for C# code, I tried and have not yet succeeded, but since I have only been programming for 2 weeks, I don’t think this will be trouble for some of you season pro’s.


This is what I have tried as requested, I thinks its faaar off but at least I tried.

            if (Title.Contains("Foo") == true && Regex.IsMatch(Title, "^Foo") == true)
        {
            CheckAnd = true;
        }
        else if (Title.Contains("Foo") == true && Regex.IsMatch(Title, "^Foo") == false)
        {
            CheckAnd = false;
        }
        else if (Regex.IsMatch(Title, "^foo"))
        {
            CheckAnd = false;
        }
        else
        {
            CheckAnd = true;
        }

Ok guys, nearly there, this is what I got from all your answers:

if (Title.IndexOf("Foo") == 0 && Title.LastIndexOf("Foo") == 0)
        {
            CheckAnd = true;
        }
        else if (Title.LastIndexOf("Foo") > 0)
        {
            CheckAnd = false;
        }
        else if(Title.Contains("foo") && Title.StartsWith("Foo") == false && PUT CHECK HERE)

The last thing I need to check that all occurrences of foo are lowercase in the last else if statement ?

  • 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-06T00:52:14+00:00Added an answer on June 6, 2026 at 12:52 am

    If I undestood it correctly this should do it !

        if (testString.IndexOf("Foo") == 0 && testString.LastIndexOf("Foo") == 0)
            // "Foo foo foo"
            return true;
        else if (testString.IndexOf("Foo") == 0 && testString.LastIndexOf("Foo") > 0)
            // "Foo foo Foo"
            return false;
        else if (testString.Contains("foo")  && testString.IndexOf("Foo") > 0)
            // "foo Foo foo" or "foo foo Foo"
            return false; 
        else if (testString.Contains("foo") && !testString.Contains("Foo"))
            // "foo foo foo"
            return true;  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

having another problem with my javascript for my table. Basically, if you look at
We are having another discussion here at work about using parametrized sql queries in
I'm having trouble moving a website from one server to another. It seems to
I'm having a tough time figuring out a tricky issue. Here is what I
I have read the various questions/answers here that basically indicate that having a clustered
I saw the other topic and I'm having another problem. The process is starting
CakePHP Newbie :) I am having trouble accessing another controller and passing that data
As many of you may already know I have been having issues with another
I made another question about two weeks ago with having trouble with the Circle
I'm having trouble navigating to a different controller view from another controller action. e.g.

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.