1

Curious of anyone knows of an easy, quick way to do regular expressions using UnicodeString in C++ Builder 2009.

Particularly for an IPv4 IP address.

James Oravec
  • 19,579
  • 27
  • 94
  • 160
  • I used the boost regex stuff shown in: http://stackoverflow.com/questions/5804453/c-regular-expressions-with-boost-regex – James Oravec Jan 20 '14 at 18:29
  • @VenomFans please post it as an answer and accept it, so other people can see which is the solution – bluish Jan 16 '17 at 09:11
  • @bluish, the solution with the most up votes is what I used plus the url reference. I no longer have access to c++ builder (different job) otherwise I'd post the exact answer for you. – James Oravec Jan 16 '17 at 14:08

1 Answers1

1

Use DEELX Regular Expression Engine, I have written a BCB wrapper for it and downloadable from here (Independent single header).

char *text = "My ip is 212.122.090.180";
TMatchResult result;
TRegex <char> regex("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b", IGNORECASE);
result = regex.Match(text, 0);
if(result.isMatched())
    printf("Found at %i-%i", result.start, result.length);
else
    printf("Not found.");
mh taqia
  • 3,506
  • 1
  • 24
  • 35