Skip to content

Commit 797650b

Browse files
committed
feat: add regex support to Search/Replace action
1 parent 72921d8 commit 797650b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

includes/admin/feedzy-rss-feeds-actions.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,14 @@ private function trim_content() {
398398
*/
399399
private function search_replace() {
400400
$content = call_user_func( array( $this, $this->current_job->tag ) );
401-
return str_replace( $this->current_job->data->search, $this->current_job->data->searchWith, $content );
401+
$search = $this->current_job->data->search;
402+
$replace = $this->current_job->data->searchWith;
403+
404+
if ( preg_match( '/^\/.*\/[imsxuADU]*$/', $search ) ) {
405+
return preg_replace( $search, $replace, $content );
406+
}
407+
408+
return str_replace( $search, $replace, $content );
402409
}
403410

404411
/**

js/ActionPopup/SortableItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const SortableItem = ({ propRef, loopIndex, item }) => {
117117
<TextControl
118118
type="text"
119119
label={__( 'Search', 'feedzy-rss-feeds' )}
120-
placeholder={__( 'Enter term', 'feedzy-rss-feeds' )}
120+
placeholder={__( 'Enter term or regex', 'feedzy-rss-feeds' )}
121121
value={ item.data.search ? unescape(item.data.search.replaceAll('&#039;', '\'')) : '' }
122122
onChange={ ( currentValue ) => propRef.onChangeHandler( { 'index': loopIndex, 'search': currentValue ?? '' } ) }
123123
/>

0 commit comments

Comments
 (0)