Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » why no virtual destructor for RegExp?
Re: why no virtual destructor for RegExp? [message #38887 is a reply to message #38795] Fri, 25 January 2013 14:58 Go to previous messageGo to previous message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
Hi All,

Just an update what I am up to so far. I manage to code a replica of preg_replace of php. due to the difference in nature of variable type, I had to almost 4 overloaded function to match all the things "preg_replace" can do in a single function definition.

	
//===================================================================================
//        My Extension to RegExp
//===================================================================================

protected:	
	bool ReplacePos(String& t, int p, int q, const String r);
	int  Replace0(String& t, Vector<String>& rv, const int& rv_count, int& offset);
	Vector<String> ResolveBackRef(Vector<String>& rv);	
	Vector<String> Make_rv(const String& r);
	

public:	

	int  ReplaceGlobal(String& t, Vector<String>& rv, const String pattern=Null, bool backref=false); //DONE
	int  ReplaceGlobal(String& t, Vector<String>& rv, int offset, const String pattern=Null, bool backref=false); //DONE

	int  ReplaceGlobal(String& t, const String r, const String pattern=Null, bool backref=false); //DONE
	int  ReplaceGlobal(String& t, const String r, int offset, const String pattern=Null, bool backref=false); //DONE

	int  ReplaceGlobal(String& t, Callback cbr, const String pattern=Null, bool backref=false); // NOT YET
	int  ReplaceGlobal(String& t, Callback cbr, int offset, const String pattern=Null, bool backref=false); //NOT YET


My plan is to implement 6 flavor of ReplaceGlobal() and 6 flavor of Replace(). all based on how replace text or callback function are given.

replace text can either be given as single String in Parentheses format just like a regular expression. ie (replace_a)(replace_b)(replace_c). Or can be given a vector containing three Strings. Also callback function can be passed in place of replace texts.

regexp pattern can also be given as argument. instead of setting it using SetPattern()

backref = is a on/off switch for resolving/expanding back reference given in replace text as /1, /2, /3 etc. where the number is the number of the match string cough by the regexp pattern.

Thanks & Regards
Navi

[Updated on: Mon, 28 January 2013 06:52]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Details when compiling in 64 bits
Next Topic: Wanted: OpenGL for gtk+ backend
Goto Forum:
  


Current Time: Mon Jun 09 17:18:33 CEST 2025

Total time taken to generate the page: 0.01106 seconds