mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-5322 update sample code in doc comments.
X-SVN-Rev: 20216
This commit is contained in:
parent
208671aabb
commit
e2e03f351c
2 changed files with 13 additions and 8 deletions
|
@ -114,13 +114,15 @@ U_NAMESPACE_BEGIN
|
|||
* and examples of how to use instances of this class to implement text
|
||||
* searching.
|
||||
* <pre><code>
|
||||
* UnicodeString target("The quick brown fox jumped over the lazy fox");
|
||||
* UnicodeString target("The quick brown fox jumps over the lazy dog.");
|
||||
* UnicodeString pattern("fox");
|
||||
*
|
||||
* SearchIterator *iter = new StringSearch(pattern, target);
|
||||
* UErrorCode error = U_ZERO_ERROR;
|
||||
* for (int pos = iter->first(error); pos != USEARCH_DONE;
|
||||
* pos = iter->next(error)) {
|
||||
* StringSearch iter(pattern, target, Locale::getUS(), NULL, status);
|
||||
* for (int pos = iter.first(error);
|
||||
* pos != USEARCH_DONE;
|
||||
* pos = iter.next(error))
|
||||
* {
|
||||
* printf("Found match at %d pos, length is %d\n", pos,
|
||||
* iter.getMatchLength());
|
||||
* }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2001-2005 IBM and others. All rights reserved.
|
||||
* Copyright (C) 2001-2006 IBM and others. All rights reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
* 06/28/2001 synwee Creation.
|
||||
|
@ -115,15 +115,18 @@
|
|||
* u_uastrcpy(pattern, patstr);
|
||||
*
|
||||
* UStringSearch *search = usearch_open(pattern, -1, target, -1, "en_US",
|
||||
* &status);
|
||||
* NULL, &status);
|
||||
* if (U_SUCCESS(status)) {
|
||||
* for (int pos = usearch_first(search, &status);
|
||||
* pos != USEARCH_DONE;
|
||||
* pos = usearch_next(search, &status)) {
|
||||
* pos != USEARCH_DONE;
|
||||
* pos = usearch_next(search, &status))
|
||||
* {
|
||||
* printf("Found match at %d pos, length is %d\n", pos,
|
||||
* usearch_getMatchLength(search));
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* usearch_close(search);
|
||||
* </code></pre>
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue