comments
This commit is contained in:
		
							
								
								
									
										16
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								main.go
									
									
									
									
									
								
							@ -11,11 +11,21 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	input         = flag.String("i", "^.*?$", "input pattern")
 | 
						// regex with sub groups
 | 
				
			||||||
	output        = flag.String("o", "{0}", "output pattern")
 | 
						input = flag.String("i", "^.*?$", "input pattern")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// format string with {0} as placeholders
 | 
				
			||||||
 | 
						// {0} always matches the whole line
 | 
				
			||||||
 | 
						// {1} and onwards match their respective sub groups
 | 
				
			||||||
 | 
						// You can optionall specify a printf-syntax for formatting like this: {1:%s} or {1:%02d}
 | 
				
			||||||
 | 
						// printf-syntax is currently supported for: strings, floats, integers
 | 
				
			||||||
 | 
						output = flag.String("o", "{0}", "output pattern")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// don't ignore lines which do not match against input.
 | 
				
			||||||
 | 
						// they will be copied without any changes
 | 
				
			||||||
	keepUnmatched = flag.Bool("k", false, "keep unmatched lines")
 | 
						keepUnmatched = flag.Bool("k", false, "keep unmatched lines")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	replacePattern = regexp.MustCompile("\\{(\\d+)(?::(.*?))?\\}")
 | 
						replacePattern = regexp.MustCompile(`\{(\d+)(?::(.*?))?\}`)
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user