die RE
Code: Alles auswählen
(?>([^;"]*("[^"]*")*[^;"]*)*)("[^"]*)?
Kann mir hier jemand weiterhelfen und auch wieso dass die in python nicht geht?
/edit.... RE korrigiert, ich benutze sie mit semikolon, statt komma...
Code: Alles auswählen
(?>([^;"]*("[^"]*")*[^;"]*)*)("[^"]*)?
.NET ist doch keine Sprache!streetfox hat geschrieben: die REfunzt in .NET.Code: Alles auswählen
(?>([^,"]*("[^"]*")*[^,"]*)*)("[^"]*)?
In dem Fall ist es aber zutreffend, da die Regulären Ausdrücke aus der .NET Library kommen und somit in jeder Sprache gleich sind.Hyperion hat geschrieben:.NET ist doch keine Sprache!streetfox hat geschrieben: die REfunzt in .NET.Code: Alles auswählen
(?>([^,"]*("[^"]*")*[^,"]*)*)("[^"]*)?
/me editiert sich zu tode>>> retest = re.compile(r'(?>([^,"]*("[^"]*")*[^,"]*)*)("[^"]*)?')
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
retest = re.compile(r'(?>([^,"]*("[^"]*")*[^,"]*)*)("[^"]*)?')
File "C:\Python30\lib\re.py", line 203, in compile
return _compile(pattern, flags)
File "C:\Python30\lib\re.py", line 271, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Python30\lib\sre_compile.py", line 491, in compile
p = sre_parse.parse(p, flags)
File "C:\Python30\lib\sre_parse.py", line 692, in parse
p = _parse_sub(source, pattern, 0)
File "C:\Python30\lib\sre_parse.py", line 315, in _parse_sub
itemsappend(_parse(source, state))
File "C:\Python30\lib\sre_parse.py", line 627, in _parse
raise error("unexpected end of pattern")
sre_constants.error: unexpected end of pattern
Hm ... ok. Ich dachte .NET garantiert nur eine Art "Binär-Kompatibilität" für unterschiedlichste Sprachen. Also gibt es aber auch einheitliche Sprachkonstrukte oder Vorschriften für .NET kompatible Sprachen?Leonidas hat geschrieben: In dem Fall ist es aber zutreffend, da die Regulären Ausdrücke aus der .NET Library kommen und somit in jeder Sprache gleich sind.
Es gibt halt eine einheitliche Klassenlibrary, wie auf der JVM auch. Also quasi eine Stdlib. Einheitliche Sprachkonstrukte gibt es in dem Sinn nicht (also von CIL abgesehen, aber das programmiert niemand direkt).Hyperion hat geschrieben:Also gibt es aber auch einheitliche Sprachkonstrukte oder Vorschriften für .NET kompatible Sprachen?
zu"Value1;";"Value2";"""Value3""";"of ""very"" ""difficult""";"";"expressions"
"and";"";"we should not ;""then""; forget";"that it
works ;"
as ""ss""
expected""
"And";"this ""is""";" a";"new start"
"And2";"this is a";"new start as well"
"only "this" line";" is malformat;ted "with" quotes"
beiNote
The reader is hard-coded to recognise either '\r' or '\n' as end-of-line, and ignores lineterminator. This behavior may change in the future.
Code: Alles auswählen
"feld1";"text kommt auf eine
neue zeile
innerhalb des records";"geht nich"
Code: Alles auswählen
DATA = '''"Value1;";"Value2";"""Value3""";"of ""very"" ""difficult""";"";"expressions"
"and";"";"we should not ;""then""; forget";"that it
works ;"
as ""ss""
expected""
"And";"this ""is""";" a";"new start"
"And2";"this is a";"new start as well"
"only "this" line";" is malformat;ted "with" quotes"'''
rows = list(csv.reader(DATA.splitlines(True), delimiter=';'))
print rows
[/code][['Value1;', 'Value2', '"Value3"', 'of "very" "difficult"', '', 'expressions'], ['and', '', 'we should not ;"then"; forget', 'that it \nworks ;'], ['as ""ss""'], ['expected""'], ['And', 'this "is"', ' a', 'new start'], ['And2', 'this is a', 'new start as well'], ['only this" line"', ' is malformat;ted with" quotes"']]