Be a Supporter!

Pattern Matching

  • 426 Views
  • 4 Replies
New Topic Respond to this Topic
Entice
Entice
  • Member since: Jun. 30, 2008
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Pattern Matching 2009-08-18 20:51:20 Reply

Okay, I'm trying to write a script that can read and edit xml.

I know that there's Python modules that I can download that will do this but I tried one and didn't like it, so I'm making my own so that I can... learn. But the problem is I don't know any pattern matching. What could I use to separate each tag, tell which tag nested inside which tag, etc?

The only things I know that are close are match() and search() and I don't think those would work. I'd need something like preg_match and preg_replace in PHP.

Also, I have a feeling that this won't exactly be easy. Is it even worth doing?

Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to Pattern Matching 2009-08-18 21:35:55 Reply

At 8/18/09 08:51 PM, bgraybr wrote: I'd need something like preg_match and preg_replace in PHP.

Does this help:
http://www.amk.ca/python/howto/regex/reg ex.html#SECTION000300000000000000000


wat
a compessor wil raise the volume while lowering the db - chronamut

Entice
Entice
  • Member since: Jun. 30, 2008
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Pattern Matching 2009-08-18 21:51:29 Reply

At 8/18/09 09:35 PM, Thomas wrote:
At 8/18/09 08:51 PM, bgraybr wrote: I'd need something like preg_match and preg_replace in PHP.
Does this help:
http://www.amk.ca/python/howto/regex/reg ex.html#SECTION000300000000000000000

Actually, I think thats exactly what I'm look for.
I'll try it and see how it goes.

fourthfrench
fourthfrench
  • Member since: Aug. 13, 2009
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Pattern Matching 2009-08-18 22:07:41 Reply

You want to read and edit xml. If you are familiar with php, just use simplexml. Unless you are trying to just write your own version for fun? Then no, I would not suggest doing it, as you would be reinventing the wheel.
~fourthfrench

dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to Pattern Matching 2009-08-22 03:15:58 Reply

At 8/18/09 10:07 PM, fourthfrench wrote: Unless you are trying to just write your own version for fun? Then no, I would not suggest doing it, as you would be reinventing the wheel.

There is absolutely nothing wrong with reinventing the wheel as you put it, it's a great learning experiance.


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature