Substring Question? 
Author Message
 Substring Question?

Hello,
I'm trying to parse a unicode string and pull a substring out of it that
begins with the character '/' and ends with a space ' '.

I know I want to use wcsstr, but how?
pdest = wcsstr( string, L"\*/");  ????

Thank you.



Wed, 09 Feb 2005 02:41:23 GMT  
 Substring Question?
From the first '/' to the last ' ', you can do this:

TCHAR pstring []         = _T("abc/def ghi");
LPTSTR pstart            = _tcschr (pstring, _T('/'));
LPTSTR pend              = _tcsrchr(pstring, _T(' '));
TCHAR pdest   [MAX_PATH] = _T("");
if (pstart != 0 && pend != 0 && pstart > pend)
{
    _tcsncpy(pdest, pstart, pend + 1 - pstart);
    pdest [pend + 1 - pstart] = 0;

Quote:
}

--
Vincenzo.


| Hello,
| I'm trying to parse a unicode string and pull a substring out of it that
| begins with the character '/' and ends with a space ' '.
|
| I know I want to use wcsstr, but how?
| pdest = wcsstr( string, L"\*/");  ????
|
| Thank you.
|
|
|



Thu, 10 Feb 2005 00:31:47 GMT  
 Substring Question?
thanks.


Quote:
> From the first '/' to the last ' ', you can do this:

> TCHAR pstring []         = _T("abc/def ghi");
> LPTSTR pstart            = _tcschr (pstring, _T('/'));
> LPTSTR pend              = _tcsrchr(pstring, _T(' '));
> TCHAR pdest   [MAX_PATH] = _T("");
> if (pstart != 0 && pend != 0 && pstart > pend)
> {
>     _tcsncpy(pdest, pstart, pend + 1 - pstart);
>     pdest [pend + 1 - pstart] = 0;
> }

> --
> Vincenzo.



> | Hello,
> | I'm trying to parse a unicode string and pull a substring out of it that
> | begins with the character '/' and ends with a space ' '.
> |
> | I know I want to use wcsstr, but how?
> | pdest = wcsstr( string, L"\*/");  ????
> |
> | Thank you.
> |
> |
> |



Fri, 11 Feb 2005 20:05:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Searching string for substring question

2. substring question

3. Substring question w/MFC

4. Getting Substring from String.LastIndexOf

5. Substring Help

6. how to delete files with substring

7. Substring

8. how to get substring

9. how to check that string contains substring?

10. substring

11. taking a substring of char*

12. strstr or strspn for finding a substring

 

 
Powered by phpBB® Forum Software