Searching patterns across multiple lines?????

Results 1 to 2 of 2

Thread: Searching patterns across multiple lines?????

  1. #1
    JB Guest

    Default Searching patterns across multiple lines?????

    Hi,<BR><BR>I have a regExp Pattern that looks like this...<BR><BR>objRegExp.Pattern = "&#060;title&#062;(.*?)&#060;/title&#062;"<BR><BR>This pattern will find the following<BR><BR>&#060;title&#062;Welcome to my Hello World Page&#060;/title&#062;<BR><BR>But it doesn&#039;t find anythin if the HTML is written like this.<BR><BR>&#060;title&#062;<BR>Welcome to my Hello World Page<BR>&#060;/title&#062;<BR><BR>Is there any way to tell the RegExp Object to search across multiple lines. Before anyone asks I have tried the MultiLine Property with no succsess.<BR><BR>objRegExp.MultiLine = True<BR><BR>I would really appreciate if someone could answer this for me. To get around this I am using a VBScript Replace function to strip out all of the Line Feed&#039;s &#039;
    &#039;. I would like to not have to go through that step if there is a way around it.<BR><BR>Thanks in advance for your help.<BR><BR>JB<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Searching patterns across multiple lines?????

    The reason is the . character match matches any character except the newline character! Ah!<BR><BR>So, you have to tell it to look for . OR a newline character.<BR><BR>objRegExp.Pattern = "&#060;title&#062;((.&#124
    )*?)&#060;/title&#062;"<BR><BR>(I think you&#039;ll need to reference $2, since there are now two sets of parenthesis. In fact, you may not need the inner set of parens, I&#039;ve not tested the code above, but it (or some slight derivation) should do the trick. Hope this helps!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts