Add-Ons & Services

RegularExpression misunderstanding...

Please post support and help requests here.
Posts: 2
Joined: 29 Nov 2007, 11:00
Location: France

RegularExpression misunderstanding...

Postby ccharron » 30 Nov 2007, 17:03


As I practised regular expressions with perl (and PHP), I was very happy when I saw Poco uses pcre in its RegularExpression class (:biggrin:)

But there's some things I don't understand (:neutral:)

1 - When I use the 'extract' method of the RegularExpression, I suppose that I can extract values from a string with the parenthesis.

Code: Select all

  RegularExpression *pMyPattern;
  std::vector sMatches;

  aString = "C:WindowsSystem32someLib.dll";
  pMyPattern = new RegularExpression(" (.*)[\\/]([\\/]+)\.([^\.]+)$");
  pMyPattern->extract(aString, anExtractedValue);
  // This line produces: "Path = C:WindowsSystem32" on output
  std::cout << "Path = " << anExtractedValue << std::endl;

The result printed is the entire string that matched the regular expression (:sad:)

2 - When I use the 'split' method, I suppose that I can deduce a string vector with all the values found in the string given as argument to the method. In fact the 'split' method used in place of the 'extract' method in previous example works as I expected in previous example (:eek:)

3 - I haven't found any 'join' method, used to glue a string vector with a separation character/string (~ join = split^-1).

4 - I think that specifying the regular expression only on the instance construction is poor. Every match we'd like to do, we had to create a new instance of the RegularExpression... (:confused:) An 'assign' method would be greatly appreciated...

Is there some user's feedback with these points ? Is there some changes planned ?

What to you think about this ?



Return to “Support”

Who is online

Users browsing this forum: No registered users and 4 guests