I actually deal with the problem of finding quotations (i.e. "this is a quotation") in larger texts of different languages, mostly German and English. Unfortunately there are several ways to fill text in quotation marks (marks differ in various languages). I tried StringCases
, but this did not work as expected:
test = "This is a „real“ test, even wit a „really longer“ citation!"
then:
StringCases[test, "„" ~~ __ ~~ "“"]
(* {"„real“ test, even wit a „really longer\
“"} *)
which is correct, but not what I intended. I also tried with RegularExpression
but could not get it to work as expected, so I got back to my "handmade" StringPosition
which gave immediate success ;-)
pos = StringPosition[test, {"„", "“"}]
and
Partition[First /@ pos, 2]
finally:
StringTake[test, %]
This works, but I think this should be no problem with a RegularExpression
or StringCases
, only, ... I could not get it to work. Can anyone give me a hint (maybe it is obvious - but I do not see it)?