Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
migrate_plus
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
migrate_plus
Commits
40e7f1c5
Commit
40e7f1c5
authored
3 years ago
by
Alison Jo
Committed by
Ivan Doroshenko
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3259471
: Improve str_replace documentation re: regex (preg_replace)
parent
46e7820e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!30
Issue #3259471: Improve str_replace documentation re: regex (preg_replace)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/migrate/process/StrReplace.php
+18
-2
18 additions, 2 deletions
src/Plugin/migrate/process/StrReplace.php
with
18 additions
and
2 deletions
src/Plugin/migrate/process/StrReplace.php
+
18
−
2
View file @
40e7f1c5
...
...
@@ -54,9 +54,12 @@ use Drupal\migrate\Row;
* foo is "/[0-9]{3}/" in search and bar is "the" in replace, field_text will be
* "vero eos et the accusam et justo the duo".
*
*
All
the rules for
*
Depending on the value of 'regex',
the rules for
* @link http://php.net/manual/function.str-replace.php str_replace @endlink
* apply. This means that you can provide arrays as values.
* or
* @link http://php.net/manual/function.preg-replace.php preg_replace @endlink
* apply. This means that you can provide arrays as values, your replace string
* can include backreferences, etc.
*
* Multiple values can be matched like this:
* @code
...
...
@@ -67,6 +70,19 @@ use Drupal\migrate\Row;
* replace: ["Austria", "Switzerland", "Denmark"]
* @endcode
*
* Replace with a regex backreference like this:
* @code
* field_text:
* plugin: str_replace
* regex: true
* source: text
* search: foo
* replace: bar
* @endcode
* If the value of text is "@username" in source,
* foo is "/@(\S+)/" in search and bar is "$1" in replace, field_text will be
* "username".
*
* @codingStandardsIgnoreEnd
*/
class
StrReplace
extends
ProcessPluginBase
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment