Easiest approach to find the substring in a string ignoring it's case senistivity

Posted on 2004-11-09
Last Modified: 2013-11-20
Hello Guys,

We have CString.Find and CString.CompareNoCase to find the substring and Ignoring the case .

Now my Question is I wanted to find a substring in a string and the search should be case insensitive. How it is possible. Is there any method available for that?? Or what is simplest approach??


Question by:sudhakar_koundinya
    LVL 48

    Accepted Solution

    Convert both string and substring using MakeUpper or MakeLower  and use Find with converted strings.
    LVL 14

    Author Comment

    Thought the same

    But Don't want to loose the Actual String.

    Only thing I can do is have a copy of original string and do the rest

    Anyways thanks for your help

    LVL 16

    Expert Comment

    If you want to find only the position of such a case insensitive substring, you can: lower/upper the string and then find your substring

    CString strToFind,strText;

    LVL 14

    Author Comment

    I thought there will be some method for this

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    cat dog challenge 18 119
    Expand to include initial dialog with two choices. 9 50
    while loop over for loop 7 69
    Change to event 1 50
    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now