Home » U++ Library support » U++ Core » Retriving data in record containing ""
Re: Retriving data in record containing "" [message #33653 is a reply to message #33649] |
Sun, 04 September 2011 10:19   |
 |
forlano
Messages: 1215 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
sergeynikitin wrote on Sat, 03 September 2011 21:29 | This very slow. I recomend use Regular Expression (package plugins/pcre)
|
Prevet Sergey,
I agree it is slow. I tried your pattern
#include <Core/Core.h>
#include <plugin/pcre/pcre.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
String ss, s = LoadFile("in.txt");
String p1 = "^((\"(?:[^\"]|\"\")*\"|[^,]*)(,(\"(?:[^\"]|\"\")*\"|[^,]*))*)$";
RegExp r0(p1);
r0.Match(s);
Vector<String> field=r0.GetStrings();
for (int i=0; i<field.GetCount(); i++) {
ss << field[i] << "\n";
}
SaveFile("out.txt", ss);
}
and in.txt is
"Luigi", "Ivan, Petrovic", "43434"
but it give me weird output. I would like to get the data inside ".
Luigi
Ivan, Petrovic
43434
Perhaps I need to modify the pattern as I have 14 fields
http://www.kimgentes.com/worshiptech-web-tools-page/2008/10/ 14/regex-pattern-for-parsing-csv-files-with-embedded-commas- dou.html
Luigi
[Updated on: Sun, 04 September 2011 10:31] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue Aug 26 08:03:16 CEST 2025
Total time taken to generate the page: 0.10694 seconds
|