Red Hat Training

A Red Hat training course is available for Red Hat CloudForms

Appendix A. Regular Expressions

In Red Hat CloudForms, regular expressions can be used to search the contents of a file for a specific string for use in a condition. Below are listed the items most commonly used with Red Hat CloudForms to search strings. These are a small subset of all the items available to use in regular expressions. If you are unfamiliar with regular expressions, there are many resources available on the Internet, including Note that if you want to search a file, you must collect it as part of a host analysis profile.

Table A.1. Regular Expressions



start of string


end of string

Character Classes



white space including spaces, tabs, and line breaks


not white space


digit, same as [0-9]


not digit




not word




0 or more of preceding characters


1 or more of preceding characters


0 or 1 of preceding character

Escape Character



put before a metacharacter to search for that actual character



^ [ . $ { * ( \ + ) | ? < >

must be used with the Escape Character if you are searching specifically for it

Special characters



new line



Groups and Ranges



any character except new line (\n)


a or b




a or b or c


not a or b or c


letter between a and q


upper case letter between A and Q


digit between 0 and 7

Pattern modifiers



case insensitive

Other helpers



swallows text between 2 words


guarantees minimum of 1 whitespace between 2 words


guarantees 0 or more whitespace between 2 words


beginning of line with zero or more whitespace


swallows all text and white space between 2 words


guarantees minimum of 1 number between 2 words


identical to <[a-zA-Z0-(_]>

Table A.2. Examples

DescriptionRegular Expression


Letters, numbers, hyphens

Find the line beginning with sshd. Then, using a colon : as delimiter, check that the value four ":" over is equal to 99999.


Verify that PASS_MAX_DAYS exists starting in position 1 and a value after it is ⇐ 90.


Verify that ROOTPW (in any case) exists on an uncommented line.


Verify that line in file starts with size and the value after is ⇐ 4096k.


Find line with string restrict that starts in position `1 to ensure it is not commented out.


Find an uncommented line that contains /home. There will be additional text before the desired string.