{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Match and replace","type":"basic","slug":"match-and-replace","excerpt":"","body":"When extracting identifiers, synonyms and descriptions from files, it is often necessary to use only a specific portion of an existing string and possibly modify it to maintain compatibility with other files.  The match and replace pattern used extensively in the Stage 2 configuration files is intended to simplify this process and to remove the need to use one-liners to generate intermediate files with compatible naming.\n\nThe pattern used is to match a regular expression within the selected string and optionally replace part of this string using a second regular expression.\n\n## Match\n\nThe simplest case is to match the entire string:\n\n```\n/(.+)/\n```\n\nTo match part of a string, either specify the pattern to match inside the parentheses, or specify a sting to exclude outside the parentheses:\n```\n/(\\w+\\d+)/\n/(.+)-PA/\n```\n\n## Replace\n\nIf specified, a second regular expression acts on the value captured during the match step and substitutes one of more characters:\n\n```\n/(.+)/ /-PA/-TA/\n```","updates":[],"order":0,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"58c10f5a2c3c720f00768b98","__v":0,"parentDoc":null,"user":"573592b84b0ab120000b7d44","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Additional documentation","slug":"additional-documentation","order":9,"from_sync":false,"reference":false,"_id":"58c10f5a2c3c720f00768b8e","__v":0,"createdAt":"2016-05-20T15:04:12.866Z","version":"58c10f5a2c3c720f00768b87","project":"5735936aafab441700723a50"},"createdAt":"2016-05-16T10:35:33.340Z","githubsync":"","project":"5735936aafab441700723a50","version":{"version":"2.0","version_clean":"2.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["58c10f5a2c3c720f00768b88","58c10f5a2c3c720f00768b89","58c10f5a2c3c720f00768b8a","58c10f5a2c3c720f00768b8b","58c10f5a2c3c720f00768b8c","58c10f5a2c3c720f00768b8d","58c10f5a2c3c720f00768b8e","58c10f5a2c3c720f00768b8f","58c10f5a2c3c720f00768b90","58c10f5a2c3c720f00768b91","58c10f5a2c3c720f00768b92","58c10f5a2c3c720f00768b93","58c11574b36d8c0f006fda47","58c2cdcafc6eed3900e97640","58c2ce8afc6eed3900e97663"],"_id":"58c10f5a2c3c720f00768b87","project":"5735936aafab441700723a50","releaseDate":"2017-03-09T08:16:26.385Z","createdAt":"2017-03-09T08:16:26.385Z","__v":4}}
When extracting identifiers, synonyms and descriptions from files, it is often necessary to use only a specific portion of an existing string and possibly modify it to maintain compatibility with other files. The match and replace pattern used extensively in the Stage 2 configuration files is intended to simplify this process and to remove the need to use one-liners to generate intermediate files with compatible naming. The pattern used is to match a regular expression within the selected string and optionally replace part of this string using a second regular expression. ## Match The simplest case is to match the entire string: ``` /(.+)/ ``` To match part of a string, either specify the pattern to match inside the parentheses, or specify a sting to exclude outside the parentheses: ``` /(\w+\d+)/ /(.+)-PA/ ``` ## Replace If specified, a second regular expression acts on the value captured during the match step and substitutes one of more characters: ``` /(.+)/ /-PA/-TA/ ```