File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,22 @@ public function count(): int {
7575 public function toRegex (): string {
7676 return $ this ->builder ->toRegex ();
7777 }
78+
79+ public function replace (callable $ replaceFunction ): string {
80+ return $ this ->builder ->replace ($ replaceFunction );
81+ }
82+
83+ public function search (string |callable $ keywordOrPattern ): mixed {
84+ return $ this ->builder ->search ($ keywordOrPattern );
85+ }
86+
87+ public function searchReverse (string |callable $ keywordOrPattern ): mixed {
88+ return $ this ->builder ->searchReverse ($ keywordOrPattern );
89+ }
90+
91+ public function swap (string |callable $ stringOrCallback ): mixed {
92+ return $ this ->builder ->swap ($ stringOrCallback );
93+ }
7894
7995 // Builder class implementation methods END
8096
Original file line number Diff line number Diff line change 437437 expect ($ replaced )->toBe ("Send to EXAMPLE-1@EMAIL.COM or replay to EXAMPLE-2@EMAIL.COM " );
438438});
439439
440+
441+ it ('Replaces hashtags with anchors ' , function () {
442+ $ replaced = EloquentRegex::start ("This is a #test to wrap hashtags in #anchor tag " )
443+ ->hash ()->text ()
444+ ->replace (function ($ foundItem ) {
445+ return "<a href=' $ foundItem'> " . $ foundItem . "</a> " ;
446+ });
447+
448+ expect ($ replaced )->toBe ("This is a <a href='#test'>#test</a> to wrap hashtags in <a href='#anchor'>#anchor</a> tag " );
449+ });
450+
440451// Search feature tests:
441452
442453it ('searches multiline string using keyword ' , function () {
You can’t perform that action at this time.
0 commit comments