Antw: Probleme bei Stringmanipulation

Roland Bauer Roland.Bauer at mediaprint.at
Sun Jan 16 10:29:23 CST 2000


* * * vienna-pm-list * * *


Wenn man die Daten kennt, funktioniert auch
folgende Spezialloesung:


#!/usr/bin/perl -w

use strict;

while (<DATA>) {
  chomp;
  
  my $translate;
  my $match = &extract_string ($_);
  
  print "INPUT: $_\n";
  print "MATCH: $match\n";
  print "---------------\n";
  
}

sub extract_string {
# extract the first quoted string from imput line and return it on
# variable $match

  my ($inputline) = @_;
  
  $inputline =~ s/^[^"]*"//; # alles wegschmeissen bis inkl Anfz am Beginn
  
  # einzelne Zeichen und Kombinationen schrittweise abarbeiten bis zum 
  # ersten Anfz das nicht als Kombination auftritt
  
  my $match;
  while ($inputline =~ s/^([^"]|\\"|"")//) {
  
     $match .= $1; # die Portionen zusammenhaengen
  }  
  
  # unescape
  $match =~ s/\\"/"/g;
  $match =~ s/""/"/g;
  
  return $match;
  
}  # sub extract_string

__DATA__
 CONTROL "Mehrere Moeglichkeiten vorhanden. Eine Markieren und  ""oeffnen"" anklicken.", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 6, 151, 18
 CONTROL "BB:155 Speichern|+Editieren,457,45,100,1155,1158,50,100,6503", -2, "STATIC", SS_LEFT | WS_CHILD | NOT WS_VISIBLE | WS_BORDER | WS_GROUP, 147, 45, 33, 20
 CONTROL "", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 6, 151, 18
 CONTROL """Anhang"" information", 102, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 47, 33, 112, 10
 CONTROL "Kommentiere (""> "") den Text", 107, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 11, 105, 112, 10
 CONTROL "Kommentiere (""> "") den ""Text""", 107, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 11, 105, 112, 10
 CONTROL "Kommentiere ("" """" "") den ""Text""", 107, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 11, 105, 112, 10
 CONTROL """Kommentiere"" (""> "") den ""Text""", 107, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 11, 105, 112, 10


###
You are subscribed to vienna-pm-list
http://www.fff.at/fff/vienna.pm/



More information about the Vienna-pm mailing list