lua-users home
lua-l archive

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


Hi Patrick,

it's really two different concepts that both deal with, well, recognizing patterns.

Regex is mostly applicable when you parse strings, and so it is in Erlang, too.

The pattern matching comes into play most prominently for function parameters lists and variable assignments.

Thus, also in Erlang, you'd have regex to parse strings and then a different application of pattern matching for assignments, which have a similar role as late object-dependant bindings in OOP languages, or the case switches of procedural languages that this replaced. In Haskell it's actually also types that you can match, in Erlang it is data structure and content.

Find some brilliant, free enlightenment here: http://learnyousomeerlang.com/syntax-in-functions#pattern-matching
and here: http://learnyouahaskell.com/syntax-in-functions#pattern-matching

Out of context it may be a bit tough but then why not read the tutorials, they are thrilling and very well made.


Henning


On 9/26/10 1:19 PM, Patrick Mc(avery wrote: Hi Scott

I am having some trouble trying to learn more about pattern matching and when to use it over regular expressions.

Trying this:
"pattern matching" vs "regular expressions"
With Google only seems to lead to discussions about regular expressions. I am hoping to avoid paying for Erlang and Prolog books.

I hope this is appropriate....maybe I can explain what I am trying to achieve.

I work with scientific instruments and right now I am trying to build a disassembler. I am assuming that all of the commands that an instrument will respond to are encoded in it's firmware. It's my goal to extract these, that way I(and others) could control instrumentation without access to it's expensive proprietary software.

Does Tamale for disassembly sound plausible?

Thanks-Patrick