|
-
Dec 16th, 2012, 12:02 AM
#1
Thread Starter
Fanatic Member
[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
)
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.
-
Dec 16th, 2012, 12:21 AM
#2
Re: ReGex Woes...
try this:
Code:
dim rgx As New Regex("\[registeredname\]\s\=\>\s(.+) ")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 16th, 2012, 12:24 AM
#3
Re: ReGex Woes...
or:
Code:
dim rgx As New Regex("\[registeredname\]\s\=\>\s((.|\s)+) ")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 16th, 2012, 01:32 AM
#4
Lively Member
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.
-
Dec 16th, 2012, 08:36 AM
#5
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)
-
Dec 16th, 2012, 10:23 AM
#6
Thread Starter
Fanatic Member
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.
-
Dec 16th, 2012, 11:45 AM
#7
Re: [RESOLVED] ReGex Woes...
regex newline match = "\r\n"
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|