I am trying to return the name of a particular company from a textfile. The company name is always displayed after the German word "Gewerbeamt" and before the html symbols. On the following extract you can see for example that the first name is "Aldingen", the second "Alfdorf" and so forth:
I have used Regex to write a pattern for this which I succesfully tested using the Online Regex testing tool (http://www.gskinner.com/RegExr/). When I try to implement this pattern it however returns null!Code:<p class="liste"><a href="gewerbeamt_11730.php">Gewerbeamt Aldingen</a><br> 78549 Spaichingen</p> <hr align="left" class="liste"><p class="liste"><a href="gewerbeamt_11640.php">Gewerbeamt Alfdorf</a><br> 73553 Alfdorf</p> <hr align="left" class="liste"><p class="liste"><a href="gewerbeamt_4474.php">Gewerbeamt Allensbach</a><br> 78462 Konstanz</p> <hr align="left" class="liste"><p class="liste"><a href="gewerbeamt_9127.php">Gewerbeamt Alleshausen</a><br> 88422 Bad Buchau</p>
Code:protected void Regex(string value) { string lsPattern = "/(?<=Gewerbeamt ).*(?=</a>)/g"; // @? // Compile the regular expression. Regex r = new Regex(lsPattern, RegexOptions.IgnoreCase); // Match the regular expression pattern against a text string. Match m = r.Match(value); string lsContent = m; // Returns null! Is this correct way of implementing? }




Reply With Quote
