doc: regex aliases update (#1832)
This commit is contained in:
		
							parent
							
								
									a65e64115a
								
							
						
					
					
						commit
						25e3cca2e1
					
				| @ -3216,29 +3216,33 @@ alias checking = assets:bank:wells fargo:checking | |||||||
| ### Regex aliases | ### Regex aliases | ||||||
| 
 | 
 | ||||||
| There is also a more powerful variant that uses a [regular expression], | There is also a more powerful variant that uses a [regular expression], | ||||||
| indicated by the forward slashes: | indicated by wrapping the pattern in forward slashes. | ||||||
|  | (This is the only place where hledger requires forward slashes around a regular expression.) | ||||||
| 
 | 
 | ||||||
|  | Eg: | ||||||
| ```journal | ```journal | ||||||
| alias /REGEX/ = REPLACEMENT | alias /REGEX/ = REPLACEMENT | ||||||
| ``` | ``` | ||||||
|  | or: | ||||||
|  | ```cli | ||||||
|  | $ hledger --alias '/REGEX/=REPLACEMENT' ... | ||||||
|  | ``` | ||||||
| 
 | 
 | ||||||
| or `--alias '/REGEX/=REPLACEMENT'`. | Any part of an account name matched by REGEX will be replaced by REPLACEMENT. | ||||||
|  | REGEX is case-insensitive as usual.  | ||||||
|  | 
 | ||||||
|  | If you need to match a forward slash, escape it with a backslash, eg `/\/=:`. | ||||||
| 
 | 
 | ||||||
| <!-- (Can also be written `'/REGEX/REPLACEMENT/'`). --> |  | ||||||
| REGEX is a case-insensitive regular expression. Anywhere it matches |  | ||||||
| inside an account name, the matched part will be replaced by |  | ||||||
| REPLACEMENT. |  | ||||||
| If REGEX contains parenthesised match groups, these can be referenced | If REGEX contains parenthesised match groups, these can be referenced | ||||||
| by the usual numeric backreferences in REPLACEMENT. | by the usual backslash and number in REPLACEMENT: | ||||||
| Eg: |  | ||||||
| 
 | 
 | ||||||
| ```journal | ```journal | ||||||
| alias /^(.+):bank:([^:]+):(.*)/ = \1:\2 \3 | alias /^(.+):bank:([^:]+):(.*)/ = \1:\2 \3 | ||||||
| ; rewrites "assets:bank:wells fargo:checking" to  "assets:wells fargo checking" | ; rewrites "assets:bank:wells fargo:checking" to  "assets:wells fargo checking" | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Also note that REPLACEMENT continues to the end of line (or on command line, | REPLACEMENT continues to the end of line (or on command line, to end of option argument),  | ||||||
| to end of option argument), so it can contain trailing whitespace. | so it can contain trailing whitespace. | ||||||
| 
 | 
 | ||||||
| ### Combining aliases | ### Combining aliases | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user