Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] What is the most appropriate scripting language



On Wed, 17 Jan 2007 11:25:42 +0900, Ian MacLean <imaclean@example.com> wrote:

On 1/16/07, Stephen J. Turnbull <stephen@example.com> wrote:

on.

> The only thing I like better in perl is the more natural syntax for
> regexes.

What are you referring to? The "target ~= regex" notation?


exactly :

import re
p = re.compile('[a-z]+')
if p.match("some text"):
   do_somthing()

in python vs :

if ( "some text" =~ /[a-z]+/ ) {
    do_somthing();
}
in perl.


Ruby is like Perl or Python in this context.
You can choose which you like.

Personally if I am going to use the matched data I do

if m = /\w\s(\w)+/.match("Some text")
  puts m[1]
end

And if I just want to know if the line matches I do:

puts "Matches" if /\w\s\w+/ =~ "Some text"

Zev


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links