Skip to content

Commit 3cbba57

Browse files
DOCSP-24704 str len cp update (#1730)
1 parent e4001e1 commit 3cbba57

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

source/reference/operator/aggregation/strLenCP.txt

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
==========================
1+
=======================
22
$strLenCP (aggregation)
3-
==========================
3+
=======================
44

55
.. default-domain:: mongodb
66

@@ -24,12 +24,12 @@ Definition
2424
syntax <agg-quick-ref-operator-expressions>`:
2525

2626
.. code-block:: javascript
27+
:copyable: false
2728

2829
{ $strLenCP: <string expression> }
2930

3031
The argument can be any valid :ref:`expression
31-
<aggregation-expressions>` as long as it resolves to an string. For
32-
more information on expressions, see :ref:`aggregation-expressions`.
32+
<aggregation-expressions>` that resolves to a string.
3333

3434
.. include:: /includes/extracts/agg-expression-null-operand-strLenCP.rst
3535

@@ -66,7 +66,7 @@ Behavior
6666

6767
The :expression:`$strLenCP` operator counts the number of code points
6868
in the specified string. This behavior differs from the
69-
:expression:`$strLenBytes` operator which counts the number of bytes in
69+
:expression:`$strLenBytes` operator that counts the number of bytes in
7070
the string, where each character uses between one and four bytes.
7171

7272
Example
@@ -75,51 +75,51 @@ Example
7575
Single-Byte and Multibyte Character Set
7676
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7777

78-
Create a ``food`` collection with the following documents:
78+
Create a ``food`` collection:
7979

8080
.. code-block:: javascript
8181

82-
db.food.insertMany(
83-
[
84-
{ "_id" : 1, "name" : "apple" },
85-
{ "_id" : 2, "name" : "banana" },
86-
{ "_id" : 3, "name" : "éclair" },
87-
{ "_id" : 4, "name" : "hamburger" },
88-
{ "_id" : 5, "name" : "jalapeño" },
89-
{ "_id" : 6, "name" : "pizza" },
90-
{ "_id" : 7, "name" : "tacos" },
91-
{ "_id" : 8, "name" : "寿司" }
92-
]
93-
)
94-
95-
96-
The following operation uses the ``$strLenCP`` operator to calculate
82+
db.food.insertMany( [
83+
{ _id: 1, name: "apple" },
84+
{ _id: 2, name: "banana" },
85+
{ _id: 3, name: "éclair" },
86+
{ _id: 4, name: "hamburger" },
87+
{ _id: 5, name: "jalapeño" },
88+
{ _id: 6, name: "pizza" },
89+
{ _id: 7, name: "tacos" },
90+
{ _id: 8, name: "寿司" }
91+
] )
92+
93+
The following example uses the ``$strLenCP`` operator to calculate
9794
the ``length`` of each ``name`` value:
9895

9996
.. code-block:: javascript
10097

101-
db.food.aggregate(
102-
[
103-
{
98+
db.food.aggregate( [
99+
{
104100
$project: {
105-
"name": 1,
106-
"length": { $strLenCP: "$name" }
101+
name: 1,
102+
length: { $strLenCP: "$name" }
107103
}
108-
}
109-
]
110-
)
104+
}
105+
] )
111106

112-
The operation returns the following results:
107+
Example output:
113108

114109
.. code-block:: javascript
115-
116-
{ "_id" : 1, "name" : "apple", "length" : 5 }
117-
{ "_id" : 2, "name" : "banana", "length" : 6 }
118-
{ "_id" : 3, "name" : "éclair", "length" : 6 }
119-
{ "_id" : 4, "name" : "hamburger", "length" : 9 }
120-
{ "_id" : 5, "name" : "jalapeño", "length" : 8 }
121-
{ "_id" : 6, "name" : "pizza", "length" : 5 }
122-
{ "_id" : 7, "name" : "tacos", "length" : 5 }
123-
{ "_id" : 8, "name" : "寿司", "length" : 2 }
124-
125-
.. seealso:: :expression:`$strLenBytes`
110+
:copyable: false
111+
112+
[
113+
{ _id: 1, name: 'apple', length: 5 },
114+
{ _id: 2, name: 'banana', length: 6 },
115+
{ _id: 3, name: 'éclair', length: 6 },
116+
{ _id: 4, name: 'hamburger', length: 9 },
117+
{ _id: 5, name: 'jalapeño', length: 8 },
118+
{ _id: 6, name: 'pizza', length: 5 },
119+
{ _id: 7, name: 'tacos', length: 5 },
120+
{ _id: 8, name: '寿司', length: 2 }
121+
]
122+
123+
.. seealso::
124+
125+
:expression:`$strLenBytes`

0 commit comments

Comments
 (0)