Solved

Get string

Posted on 2001-06-20
6
186 Views
Last Modified: 2010-04-02
This is what i need.

A way to get as string in between two other strings...

has to use cstring and has to be really fast..

thanx
0
Comment
Question by:neo23
  • 3
  • 2
6 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6210014
Give an example of what exactly you're looking for.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6210044
CString data = "Hello Bob.  How are you?";
//First method
strncpy(data.LockBuffer()+6,"Tom",3);
data.UnlockBuffer();
//Second method
data.Replace("Tom", "Kay");
//Third method
strncpy(data.GetBuffer(10)+6,"Joe",3);

The above are a few method.  Not sure what exactly you need.  Please provide additional information.
0
 

Author Comment

by:neo23
ID: 6210477
<here is a string>i want everything between</and here>

needs to be very fast
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:neo23
ID: 6210487
<style>
want everything that is between
</style>
0
 
LVL 30

Accepted Solution

by:
Axter earned 50 total points
ID: 6210562
Example:
CString LeftKey = "<style>";
CString RightKey = "</style>";
CString szdata = "<style>want everything that is between</style><style>Want here again</style>";
CString szReplace = "Hello World";
int Start = 0;
while(szdata.Find(LeftKey,Start) > -1)
{
     Start = szdata.Find(LeftKey,Start);
     int End = szdata.Find(RightKey,Start);
     CString LeftSide = szdata.Left(Start+LeftKey.GetLength());
     CString RightKey = szdata.Mid(End);
     szdata = LeftSide + szReplace + RightKey;
     Start += LeftKey.GetLength();
}
0
 
LVL 22

Expert Comment

by:nietod
ID: 6222865
Does anyone know if this accepted answer was posted as a comment or as an answer?
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

815 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

8 Experts available now in Live!

Get 1:1 Help Now