Difference between revisions of "Regex regular expressions"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
| Line 15: | Line 15: | ||
</source>  | </source>  | ||
;Join 2 lines with colon  | |||
<source>  | <source>  | ||
Find what: ^(.*)[\r\n]+  | Find what: ^(.*)[\r\n]+  | ||
Replace with: '\1: ' #single quotes are not needed  | Replace with: '\1: ' #single quotes are not needed  | ||
</source>  | |||
Before:  | |||
{| class="wikitable"  | |||
|+ Join 2 lines with colon  | |||
|-   | |||
! Before  | |||
! After  | |||
|- style="vertical-align:top;"  | |||
| <source>  | |||
Extensions  | Extensions  | ||
None  | None  | ||
| Line 28: | Line 37: | ||
Name  | Name  | ||
bastion-1 (All resources to be created)  | bastion-1 (All resources to be created)  | ||
</source>  | |||
| <source>  | |||
Extensions: None  | Extensions: None  | ||
Cloud init: No  | Cloud init: No  | ||
| Line 35: | Line 44: | ||
bastion-1 (All resources to be created)  | bastion-1 (All resources to be created)  | ||
</source>  | </source>  | ||
|}  | |||
; Resources  | |||
*[https://stackoverflow.com/questions/5876296/regex-remove-lines-containing regex-remove-lines-containing] Stackoverflow  | *[https://stackoverflow.com/questions/5876296/regex-remove-lines-containing regex-remove-lines-containing] Stackoverflow  | ||
Revision as of 16:36, 10 November 2019
General expressions
+ -unlimited string \ -escape/protect character /[abc]+/ -matches a bb ccc
PCRE Perl Compatible Regular Expressions
This also covers Notepad ++
regex like [\r\n]+ matches CRLF in Notepad ++
Notetad++ | npp | npp++
Find, replace and remove matching line. Find any occurances of help</help>, ending with \r?\n. \r is optional in case the file doesn't have Windows line endings.
Find what: ^help\r?\n
Replace with:
- Join 2 lines with colon
 
Find what: ^(.*)[\r\n]+
Replace with: '\1: ' #single quotes are not needed
Join 2 lines with colon
 
Before
 
After
  
Extensions
None
Cloud init
No
TAGS
Name
bastion-1 (All resources to be created)
 
Extensions: None
Cloud init: No
TAGS: Name
bastion-1 (All resources to be created)
 
- Resources
 
- regex-remove-lines-containing Stackoverflow
 
Forepoint aka legacy name Websense
It accepts reg expresions with limited form example:
- (.) -same as * wildcard matches any length of string and brackets are Reg-ex delimiters
 
References
- regex101.com Dynamic RegEx builder