Results 1 to 7 of 7

Thread: [RESOLVED] ReGex Woes...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Resolved [RESOLVED] ReGex Woes...

    Hello everybody, I am trying to pull data from a PHP Array.

    The information is as follows:

    PHP Code:
    Array
    (
        [
    status] => Expired
        
    [registeredname] => First Last
        
    [companyname] => My Company
        
    [email] => my@email.com
        
    [serviceid] => 1
        
    [productid] => 1
        
    [productname] => Yearly License
        
    [regdate] => 2012-10-29
        
    [nextduedate] => 2012-11-29
        
    [billingcycle] => Monthly
        
    [validdomain] => notimportant
        
    [validip] => 127.0.0.1
        
    [validdirectory] => /home/hidden/public_html/members
        
    [md5hash] => 3afc53edbdba2f2dd51499a88128302d
        
    [remotecheck] => 1
    )


    The code I have attempted was as follows:

    PHP Code:
                Dim rgx As New Regex("\[registeredname\] => (.+) " vbLf)
                
    Dim matchG As MatchCollection rgx.Matches(src)
                
    Dim result As String matchG(0).Groups(1).ToString()
                Return 
    result 
    However, nothing I do seems to work.

    Am I missing something? I have tried vbNewLine, vbLf (what shows up in the expression editor), etc, etc, etc. Even using software such as RegEx Buddy, I have been unable to figure this out.


    Thank you in advance.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: ReGex Woes...

    try this:

    Code:
    dim rgx As New Regex("\[registeredname\]\s\=\>\s(.+) ")

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: ReGex Woes...

    or:

    Code:
    dim rgx As New Regex("\[registeredname\]\s\=\>\s((.|\s)+) ")

  4. #4
    Lively Member Blupig's Avatar
    Join Date
    Apr 2008
    Posts
    118

    Re: ReGex Woes...

    If you don't want to use Regex at all, you could totally just split the array text into different lines then use substring to take out what you want. That's the easy way out, though.

  5. #5
    Fanatic Member ThomasJohnsen's Avatar
    Join Date
    Jul 2010
    Location
    Denmark
    Posts
    528

    Re: ReGex Woes...

    When working with multiline strings, i prefer using the RegexOptions.Multiline option. It will change the meaning of ^ and $ from beginning respectively end of string to beginning respectively end of line, avoiding having to scan for newline characters and similar. In your case it's irrelevant, since you're only after one line, but if you had to parse the entire Array structure, it would be much simpler imo.
    In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: ReGex Woes...

    Thanks everybody for the info.

    BluPig, your idea is quite simple and im wondering why I didn't think of it. Thanks.

    .paul. thanks for the code snippets. the 1st code snippet only displays the 1st name, but not the 2nd.
    the second code snippet displays the full name and every line after. Even modifying it and including like "& vbLf(or Vbnewline) it still wouldn't break it up. But I appreciate it regardless.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: [RESOLVED] ReGex Woes...

    regex newline match = "\r\n"

Posting Permissions

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



Click Here to Expand Forum to Full Width