File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1187,6 +1187,21 @@ public function testStripTags()
1187
1187
$ this ->assertSame ('<strong>before</strong><br>after ' , (string ) $ this ->stringable ('<strong>before</strong><br>after ' )->stripTags ('<br><strong> ' ));
1188
1188
}
1189
1189
1190
+ public function testReplaceMatches ()
1191
+ {
1192
+ $ stringable = $ this ->stringable ('Hello world! ' );
1193
+ $ result = $ stringable ->replaceMatches ('/world/ ' , function ($ match ) {
1194
+ return strtoupper ($ match [0 ]);
1195
+ });
1196
+
1197
+ $ this ->assertSame ('Hello WORLD! ' , $ result ->value );
1198
+
1199
+ $ stringable = $ this ->stringable ('apple orange apple ' );
1200
+ $ result = $ stringable ->replaceMatches ('/apple/ ' , 'fruit ' , 1 );
1201
+
1202
+ $ this ->assertSame ('fruit orange apple ' , $ result ->value );
1203
+ }
1204
+
1190
1205
public function testScan ()
1191
1206
{
1192
1207
$ this ->assertSame ([123456 ], $ this ->stringable ('SN/123456 ' )->scan ('SN/%d ' )->toArray ());
You can’t perform that action at this time.
0 commit comments