# regular expressions: node definition

Hi,

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 database01.domain.com for example?

Quindoo

EDIT: I managed to get it working using /^database\d+$/ and /^database/d+.subdomain.domain.com/ EDIT: One final question, is it possible ... edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted 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 /\.subdomain\.domain\.com$/

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

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.

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

noticed the html ate my backslashes, added back in.

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

It worked without the backslashes aswell, I used /.subdomain.domain.com/ What is the reason behind using backslashes in front of each dot? Also the $seems useless aswell. ( 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)

( 2013-12-05 12:20:48 -0500 )edit