Hi all you brilliant people who I keep bothering with seemingly simple questions (after the fact, at least!)
<http://stackoverflow.com/questions/42935610/regex-match-the-first-occurance-of-a-word-from-a-list-of-desired-words#> I seem to have hit upon a corner case - or it's so easy, no one has ever asked! I have a list of desired words I'd like to match in a block of text. However, I only want to match the first occurrence of *each* of these. If my block of text reads: glass shoes door doors window door glasses. glass's glass window windows glasses I'd like to match: glass door window I'm learning how to narrow it down as I try to understand the groupings... This: /(?:[\s]|^)door|glass|window(?=[\s]|$)/g; gives me "ghost" occurrences: glass, door, door,window, door,glass,glass,glass,window,glass Wrapping my desired words in brackets as a set (group?) like this: /(?:[\s]|^)(door|glass|window)(?=[\s]|$)/g; gives me only every actual occurrence: glass, door, window, door, glass, window which is so far the best (narrowest) I can get. I would have expected that: /(door|glass|window)/ without the /g global flag would give me the first occurrence of "my" OR "desired" OR "words", but it stops at the first find, "glass". So to restate the question, I'm trying to find the first instance of *each* of these words (first of door, and first of window, and first of glass) wrapped by (?:[\s]|^) and (?=[\s]|$), in a block of text. Many thanks! -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/tiddlywikidev. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/664251e5-542c-44c5-95a0-52197e46a56e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
