Solved

Get string

Posted on 2001-06-20
6
184 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PCH Sample and Makefile 14 71
how to understand recursion 12 206
Header of docx file 17 60
Safe conversion? 4 21
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

746 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

15 Experts available now in Live!

Get 1:1 Help Now