#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    3
    Rep Power
    0

    Extract content between blank lines


    Can someone help me out to regex only SSID line. SSID line can be anything.

    >>> CONNECTION <<<

    SsID

    Mac: 00:ff:ff:12:00:01
    IP : 192.168.1.29
    Sig: 8
    Spd: 58Mbps
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    843
    Rep Power
    496
    Sorry, I don't understand what you need. Can you provide an example of your input data and of what you want to extract from that?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    3
    Rep Power
    0
    >>> CONNECTION <<<

    any ssid name --> contents of this line should be extracted

    Mac: 00:ff:ff:12:00:01
    IP : 192.168.1.29
    Sig: 8
    Spd: 58Mbps

    In other words I need something like
    Do not match [^>>> CONNECTION <<<] then match anything after blank line then do not match anything after next line. I already spent a lot of time on it and I just can't figure it out the correct way using regex.
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    If you actually say what you want rather than pointing to examples, you'll be much closer to the solution.

    Describe the pattern in English. This is the important part. And then we'll help you translate it into regex syntax.


    // OK, I see there's a misunderstanding.

    You have two options here: You can search for the whole block and save the SSID line in a capturing group. Or you can use lookbehinds and lookaheads to search for the SSID line based on the ">>> CONNECTION <<<" line which comes before it.

    I suggest you start with the whole pattern:

    Code:
    The string ">>> CONNECTION <<<" followed by an empty line (that's two newline sequences) followed by another line (i. e. all characters until a newline sequence)
    Last edited by Jacques1; November 18th, 2013 at 03:09 PM.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    3
    Rep Power
    0
    Thank you for pointing me to the right directions now I've got a lot of reading to do to figure it out.

IMN logo majestic logo threadwatch logo seochat tools logo