Solved

Get string

Posted on 2001-06-20
6
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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 Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

627 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