Click here to Skip to main content
15,072,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using Visual Studio 2010 .net 4 and WPF

I have collection of names of paragraphs named as FavoriteBookmarksCollection drawn from a flowdocument named as BeforeSortDocument .

For each item in FavoriteBookmarkCollection, the item will be modified to represent a paragraph name of "S" language to get the paragraph from the flowdocument and also the same item will be again modified to represent English Language which is a translation of the other language.

First selection of paragraph is "S" language and followed by "E" language. I have to select both the paragraphs from BeforeSortDocument into another document using linq query.

My not working query in is:
dim RequiredParaCollection = (From para in ParasOfBeforeSortDocument
where (Regex.IsMatch(,"B\d{4}S\d{2}") Or regex.ismatch(,"B\d{4}E\d{2}")
Select ctype(LogicalTreeHelper.FindLogicalNode(BeforeSortDocument,

ParasOfBeforeSortDocument is a readonlyCollection(of Paragraph) and is OK.
BeforeSortDocument is flowdocument and is without any error.

I request help from YOU to write two conditions in 'Where' one follows another and get the paragraphs of the document in that order.

Updated 28-Oct-14 17:46pm

I'd suggest to download: LINQ - Sample Queries[^]. There you'll find 101 examples ;)

Please, have a look here: Linq: Where clause (VB)[^] and here: How to: Combine LINQ Queries with Regular Expressions[^]. I think, you do combine where and regex in wrong way.

Using Linq with Regular Expression results[^]

Good luck!
The link using regex queries is good. In my case, it has become more complex. So I solved this using non regex queries.
My solution using linq in single line
dim paraList =(from x in bookmarks select x
Let sanskritParaName = skeletonId + Format(value, "00")
from para in paras where para isnot nothing andalso ( or"S","E")) andalso not bookmarkCollection.contains(x)
Let englishtext = sanskritParaName.Substring(1, 4) + If(value < 10, "0", "")
Let f = ModifiedParagraphUtility(para, englishtext)
Select f).ToList
This has worked perfectly. I tested it using variations. Finally I added paraList to document blocks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900