private DTDEntity CreateEntityFromQuellcode(string entityQuellcode) { string pattern = "(?<entity><!ENTITY[\\t\\r\\n ]+(?:(?<prozent>%)[\\t\\r\\n ]+)?(?<entityname>[\\w-_]+?)[\\t\\r\\n ]+\"(?<inhalt>[^>]+)\"[\\t\\r\\n ]?>)"; Regex regex = new Regex(pattern); Match match = regex.Match(entityQuellcode); if (!match.Success) { throw new ApplicationException(string.Format(ResReader.Reader.GetString("NichtsImEntityCode"), entityQuellcode)); } DTDEntity dTDEntity = new DTDEntity(); dTDEntity.IstErsetzungsEntity = match.Groups["prozent"].Success; if (!match.Groups["entityname"].Success) { throw new ApplicationException(string.Format(ResReader.Reader.GetString("KeinNameImEntityCode"), entityQuellcode)); } dTDEntity.Name = match.Groups["entityname"].Value; if (!match.Groups["inhalt"].Success) { throw new ApplicationException(string.Format(ResReader.Reader.GetString("KeinInhaltImEntityCode"), entityQuellcode)); } dTDEntity.Inhalt = match.Groups["inhalt"].Value; match = match.NextMatch(); if (match.Success) { throw new ApplicationException(string.Format(ResReader.Reader.GetString("MehrAlsEinsImEntityQuellCode"), entityQuellcode)); } return(dTDEntity); }
private void EntitiesAuslesen() { string pattern = "(?<entity><!ENTITY[\\t\\r\\n ]+[^>]+>)"; Regex regex = new Regex(pattern); Match match = regex.Match(this._workingInhalt); while (match.Success) { string value = match.Groups["entity"].Value; DTDEntity item = this.CreateEntityFromQuellcode(value); this._entities.Add(item); match = match.NextMatch(); } }