Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Re: Need help trying to find a certain pattern

  •  05-03-2007, 12:27 PM

    Re: Need help trying to find a certain pattern

    Okay, I'll try to help. Please consider being more specific next time. First of all here's your text again, in monospace this time:

    --------------------
    Approver Information
    --------------------
    Approver Interfac Linked Heir Notifier User
    List Typ Entity Approver Approver Order Type List
    -------- -------- -------- -------- ----- -------- --------------------------------------------

    The bold part is what you want, right? Are there always 20 dashes in the line before and 20 dashes in the line after? Or depends the number of dashes on the length of the string? If so, is there a minimum length to those strings? Can the text to be found consist of more than one line? Are their more lines starting with dashes in your file?

    Here are some patterns that might work (using multiline pattern modifier): 

    Always 20 dashes:

    (?m)^-{20}\s+^(.*?)\s+^-{20}

    Number of dashes in line before equals number of dashes in line after:

    (?m)^(-+)\s+^(.*?)\s+^\1

    Edit:

    Ah, you gave more specifics while I replied. So the length of the dashes depends on the string you are looking for. My second pattern should work for you.

    I can't discern if there's a space character in front of the dashes. If there is, then you might try this:

    (?m)^(\s-+)\s+^\s(.*?)\s+^\1
    Filed under: ,
View Complete Thread