Multiple Regular Expressions
Posted: Sat Jun 09, 2007 3:07 am
Hi there,
I have a different XML Document's which each require different regular expression's performed on them. These regular expressions are going to change over time. At the moment I have a base Parser class which does things which are common to all documents, then an additional class for each document to do the regular expression's which are unique to it. Regular Expressions are not the only manipulation we are doing on these documents.
At the moment my base class has a doRegexReplace() method and in my child classes for the documents I just have a couple $this->doRegexReplace() function calls. However I have some really long nasty replaces in here and because the matches and replace strings are in the code I have no way of writing Unit Tests to test these expressions. The source XML is changing all the time, so I would need to test that just a certain section changes to the new value. Anyone have any ideas where I can put my find -> replace terms to have easy access to them in my code and unit tests? I don't want to use an XML file because the matches and replace's contain XML aswell.
Thanks Jamie
I have a different XML Document's which each require different regular expression's performed on them. These regular expressions are going to change over time. At the moment I have a base Parser class which does things which are common to all documents, then an additional class for each document to do the regular expression's which are unique to it. Regular Expressions are not the only manipulation we are doing on these documents.
At the moment my base class has a doRegexReplace() method and in my child classes for the documents I just have a couple $this->doRegexReplace() function calls. However I have some really long nasty replaces in here and because the matches and replace strings are in the code I have no way of writing Unit Tests to test these expressions. The source XML is changing all the time, so I would need to test that just a certain section changes to the new value. Anyone have any ideas where I can put my find -> replace terms to have easy access to them in my code and unit tests? I don't want to use an XML file because the matches and replace's contain XML aswell.
Thanks Jamie