Tag Archives: Regular Expression

Puppet – Add or Replace a string in a file

We can use the file_line type reference to append or substitute a string inside a file with regular expression.

Add a string

file { '/tmp/eureka.txt':
  ensure => present,
}->
file_line { 'Append a line to /tmp/eureka.txt':
  path => '/tmp/eureka.txt',  
  line => 'Hello World',
}

Continue reading Puppet – Add or Replace a string in a file

PHP – Convert URL into clickable link with UrlLinker

Yesterday we have talked about converting URL into clickable link by Regular Expression.
PHP – Convert URL into clickable link by Regular Expression

If you want a more complete and robust solution, you can try the UrlLinker written by Søren Løvborg.
Continue reading PHP – Convert URL into clickable link with UrlLinker

CakePHP – Email Validation

After working for about one year, the BHJS Alumni website phase 2 is completed. But after it is deployed in production server, i found that some email addresses are regarded as invalid email address. The email validation rule which i used is provided by CakePHP. Only email addresses ended with .com, .org etc… could pass the validation rule.

So i ask the Google teacher and luckily i am not the only one to come across this problem.
Continue reading CakePHP – Email Validation