Ask Your Question

regular expressions: node definition

asked 2013-12-04 02:57:16 -0500

Quindoo gravatar image

updated 2013-12-04 04:11:13 -0500


I am working on defining nodes using regular expressions. The names of my servers will excist of the server role, a number (01 and counting), and the domain name.

In the examples they show definities with www1 and counting but I can't combine that method with other methods.

What would be the best way to define a server using regular expressions if the server was called for example?

Thanks in advance,


EDIT: I managed to get it working using /^database\d+$/ and /^database/

EDIT: One final question, is it possible ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-12-04 11:13:51 -0500

ramindk gravatar image

updated 2013-12-05 04:19:01 -0500

You can build and test your regex expressions using Rubular though make sure you choose the matching Ruby of your Puppet install.

The regex I would use for your subdomain problem


I think it's more correct to escape the dots as I've done above, but it should still work without doing so.

edit flag offensive delete link more


Thank you, that seems to be the working answer. Also, thanks for providing the suggestion towards using Rubular. I will try it out the next time.

Quindoo gravatar imageQuindoo ( 2013-12-05 01:58:26 -0500 )edit

noticed the html ate my backslashes, added back in.

ramindk gravatar imageramindk ( 2013-12-05 04:19:50 -0500 )edit

It worked without the backslashes aswell, I used / What is the reason behind using backslashes in front of each dot? Also the $ seems useless aswell.

Quindoo gravatar imageQuindoo ( 2013-12-05 06:12:03 -0500 )edit

The dot has a special meaning within Regex and means any character. If you test with Rubular you'll notice that www01TsubdomainTdomainTcom will match. The $ also means start matching from ...(more)

ramindk gravatar imageramindk ( 2013-12-05 12:20:48 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-12-04 02:57:16 -0500

Seen: 2,619 times

Last updated: Dec 05 '13