1

My program get configuration from comandline. the comandline is like this: "mapPath=Some_Path_Over_Here\npluginsPath=Other_Path_Over_Here\n" please notice the "\n" in the middle and in the end.

my cose is:

QString config("mapPath=Some_Path_Over_Here\npluginsPath=Other_Path_Over_Here\n")
QRegExp reg("mapPath=(.*)\\npluginsDir=(.*)\\n");

but when I write

reg.indexIn(config)

the result is -1.

It is important to say that I my program is both for linux and windows. I think what is causing the problem is the "\n".. I dont know how to handle it. help please?

kakush
  • 3,334
  • 14
  • 47
  • 68

1 Answers1

0

config contains two line-feed characters (ASCII 0x0A, written in C++ literals as \n), but you're trying to match them against a regular expression \n (two characters, ASCII 0x5C 0x6E, written in C++ literals as \\n). This can't work - change the regex to just \n as well.

Bear in mind that turning \n into a newline charcter is the job of the C++ parser; regular expressions don't do that.

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455