Note that there are some explanatory texts on larger screens.

plurals
  1. POVBA Multilevel Regex or improved Pattern?
    text
    copied!<p>I have a problem processing a regex in VB. My Text is: </p> <blockquote> <p>is sadly currently in Toronto main station undetermined late</p> </blockquote> <p>I tested my regex in Expresso and found this regex for my purpose. The thing is: Toronto main station can also be only "Toronto". So this is my pattern:</p> <pre><code>is sadly currently in (([A-Za-z]*)(\s|-)){1,3}(.|\s)*?undetermined </code></pre> <p>The problem is processing the regex in VB, because my Pattern gives me a result like this:</p> <ul> <li>is sadly currently in Toronto main station undetermined <ul> <li>undetermined <ul> <li>Toronto</li> <li>Main</li> <li>undetermined</li> </ul></li> <li>undetermined <ul> <li>Toronto</li> <li>Main</li> <li>undetermined ....</li> </ul></li> </ul></li> </ul> <p>But I cannot access the words toronto and main via VB - also I dont want 'undetermined' be part of the result. I tried <code>match.item(0).submatches.item(0).submatches.item(0)</code> but VBA already throws an error if I try <code>match.item(0).submatches.item(0).submatches</code> and states that there is no such object - obviously it cannot process some those "multilevel" regexes. Is there a way to improve my pattern so that I only have to use one submatches or is it possible to use multiple submatches via VBA?!</p> <p>Edit:</p> <pre><code>GetDelay.Pattern = is sadly currently in (([A-Za-z]*)(\s|-)){1,3}(.|\s)*?undetermined" GetDelay.IgnoreCase = True GetDelay.Multiline = True ... If GetDelay.TEst(MailBody) Then Set m = GetDelay.Execute(MailBody) If m.Item(0).SubMatches.Count &gt; 0 Then OrtBody = m.Item(0).SubMatches.Item(0).SubMatches.Item(0) + " " + m.Item(0).SubMatches.Item(0).SubMatches.Item(1) 'Error 424 comes here - Object required If GetReason.TEst(AbweichungsmailBody) Then Set m = GetReason.Execute(AbweichungsmailBody) If m.Item(0).SubMatches.Count &gt; 0 Then Reason= m.Item(0).SubMatches.Item(0) Else Reason= "Error!" End If Else Reason = "Keine Angabe gefunden!" End If Else thisfunction= False End If Else thisfunction= False End If </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload