Regex regular expressions

From Ever changing code
Jump to navigation Jump to search

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

Before:
Extensions
None
Cloud init
No
TAGS
Name
bastion-1 (All resources to be created)

After:
Extensions: None
Cloud init: No
TAGS: Name
bastion-1 (All resources to be created)

Resources

Websense now owned and called Forepoint

It accepts reg expresions with limited form example:

  • (.) -same as * wildcard matches any lengh of string and brackets are RegEx delimiters

References